From fa1ed01cd72246b91f94a5996e5f19a05201931f Mon Sep 17 00:00:00 2001 From: Patrick Rodrigues <263442757+patrickrodrigues-aa@users.noreply.github.com> Date: Thu, 7 May 2026 11:43:27 -0600 Subject: [PATCH] Run SwayOSD as a session service (#5656) * Run SwayOSD as a session service * Restart SwayOSD after clean exits * We don't need the input backend (as we manage the hotkeys in Hyprland) * Ensure we cleanup the old service starter * Not needed * Not needed either * Clean up migration --------- Co-authored-by: David Heinemeier Hansson --- bin/omarchy-first-run | 1 + bin/omarchy-restart-swayosd | 6 +++++- config/systemd/user/swayosd-server.service | 13 +++++++++++++ default/hypr/autostart.conf | 1 - install/first-run/swayosd.sh | 2 ++ migrations/1778171768.sh | 12 ++++++++++++ 6 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 config/systemd/user/swayosd-server.service create mode 100644 install/first-run/swayosd.sh create mode 100644 migrations/1778171768.sh diff --git a/bin/omarchy-first-run b/bin/omarchy-first-run index 6ad54141..023d1a65 100755 --- a/bin/omarchy-first-run +++ b/bin/omarchy-first-run @@ -16,6 +16,7 @@ if [[ -f $FIRST_RUN_MODE ]]; then bash "$OMARCHY_PATH/install/first-run/firewall.sh" bash "$OMARCHY_PATH/install/first-run/dns-resolver.sh" bash "$OMARCHY_PATH/install/first-run/gnome-theme.sh" + bash "$OMARCHY_PATH/install/first-run/swayosd.sh" bash "$OMARCHY_PATH/install/first-run/gtk-primary-paste.sh" bash "$OMARCHY_PATH/install/first-run/elephant.sh" omarchy-hook-install post-update "$OMARCHY_PATH/install/first-run/install-voxtype.hook" diff --git a/bin/omarchy-restart-swayosd b/bin/omarchy-restart-swayosd index 19f4e78d..22a14217 100755 --- a/bin/omarchy-restart-swayosd +++ b/bin/omarchy-restart-swayosd @@ -2,4 +2,8 @@ # omarchy:summary=Restart the SwayOSD server -omarchy-restart-app swayosd-server +if systemctl --user is-enabled --quiet swayosd-server.service; then + systemctl --user restart swayosd-server.service +else + omarchy-restart-app swayosd-server +fi diff --git a/config/systemd/user/swayosd-server.service b/config/systemd/user/swayosd-server.service new file mode 100644 index 00000000..55c7f9c2 --- /dev/null +++ b/config/systemd/user/swayosd-server.service @@ -0,0 +1,13 @@ +[Unit] +Description=SwayOSD server +PartOf=graphical-session.target +After=graphical-session.target + +[Service] +Type=simple +ExecStart=/usr/bin/swayosd-server +Restart=always +RestartSec=2 + +[Install] +WantedBy=graphical-session.target diff --git a/default/hypr/autostart.conf b/default/hypr/autostart.conf index 394a5f32..5cdb875d 100644 --- a/default/hypr/autostart.conf +++ b/default/hypr/autostart.conf @@ -3,7 +3,6 @@ exec-once = uwsm-app -- mako exec-once = ! omarchy-toggle-enabled waybar-off && uwsm-app -- waybar exec-once = uwsm-app -- fcitx5 --disable notificationitem exec-once = uwsm-app -- swaybg -i ~/.config/omarchy/current/background -m fill -exec-once = uwsm-app -- swayosd-server exec-once = /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 exec-once = omarchy-first-run exec-once = omarchy-powerprofiles-init diff --git a/install/first-run/swayosd.sh b/install/first-run/swayosd.sh new file mode 100644 index 00000000..49db63f3 --- /dev/null +++ b/install/first-run/swayosd.sh @@ -0,0 +1,2 @@ +systemctl --user daemon-reload +systemctl --user enable --now swayosd-server.service diff --git a/migrations/1778171768.sh b/migrations/1778171768.sh new file mode 100644 index 00000000..ae7e5789 --- /dev/null +++ b/migrations/1778171768.sh @@ -0,0 +1,12 @@ +echo "Run SwayOSD as a supervised session service" + +mkdir -p ~/.config/systemd/user +cp "$OMARCHY_PATH/config/systemd/user/swayosd-server.service" ~/.config/systemd/user/swayosd-server.service + +if [[ -f ~/.config/hypr/autostart.conf ]]; then + sed -i '/^exec-once = uwsm-app -- swayosd-server$/d' ~/.config/hypr/autostart.conf +fi + +pkill -x swayosd-server || true + +bash "$OMARCHY_PATH/install/first-run/swayosd.sh"