From a1dbd4747d9b65d98388995b2e9243a9968015d5 Mon Sep 17 00:00:00 2001 From: Ryan Kavanagh Date: Wed, 19 Feb 2025 12:36:07 -0500 Subject: Refactor sway config to let systemd manage subservices like kanshi and swayidle --- dot_config/sway/config | 6 +----- .../symlink_swaybg-random.service | 1 - dot_config/systemd/user/kanshi.service | 14 ++++++++++++++ dot_config/systemd/user/sway-session-pre.target | 18 ++++++++++++++++++ dot_config/systemd/user/sway-session.target | 20 ++++++++++++++++---- dot_config/systemd/user/swaybg-random.service | 5 ++--- dot_config/systemd/user/swayidle.service | 14 ++++++++++++++ dot_config/systemd/user/wayland-session-pre.target | 18 ++++++++++++++++++ dot_config/systemd/user/wayland-session.target | 18 ++++++++++++++++++ .../symlink_kanshi.service | 1 + .../symlink_swaybg-random.service | 1 + .../symlink_swayidle.service | 1 + 12 files changed, 104 insertions(+), 13 deletions(-) delete mode 100644 dot_config/systemd/user/default.target.wants/symlink_swaybg-random.service create mode 100644 dot_config/systemd/user/kanshi.service create mode 100644 dot_config/systemd/user/sway-session-pre.target create mode 100644 dot_config/systemd/user/swayidle.service create mode 100644 dot_config/systemd/user/wayland-session-pre.target create mode 100644 dot_config/systemd/user/wayland-session.target create mode 100644 dot_config/systemd/user/wayland-session.target.wants/symlink_kanshi.service create mode 100644 dot_config/systemd/user/wayland-session.target.wants/symlink_swaybg-random.service create mode 100644 dot_config/systemd/user/wayland-session.target.wants/symlink_swayidle.service (limited to 'dot_config') diff --git a/dot_config/sway/config b/dot_config/sway/config index 562f48a..80c392e 100644 --- a/dot_config/sway/config +++ b/dot_config/sway/config @@ -28,10 +28,6 @@ for_window [con_mark=$alphamark] opacity set $trans include /etc/sway/config-vars.d/* ### Idle configuration -exec swayidle -w \ - timeout 180 $lock \ - timeout 240 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \ - before-sleep $lock for_window [app_id="dspdfviewer"] inhibit_idle focus ### Input configuration @@ -196,5 +192,5 @@ exec_always pkill kanshi; exec kanshi font pango:Iosevka Regular 8 -include /etc/sway/config.d/* +include /etc/sway/config.d/50-systemd-user.conf include ~/.config/sway/config.d/* diff --git a/dot_config/systemd/user/default.target.wants/symlink_swaybg-random.service b/dot_config/systemd/user/default.target.wants/symlink_swaybg-random.service deleted file mode 100644 index 2ebb1f9..0000000 --- a/dot_config/systemd/user/default.target.wants/symlink_swaybg-random.service +++ /dev/null @@ -1 +0,0 @@ -/home/rak/.config/systemd/user/swaybg-random.service diff --git a/dot_config/systemd/user/kanshi.service b/dot_config/systemd/user/kanshi.service new file mode 100644 index 0000000..381b9e4 --- /dev/null +++ b/dot_config/systemd/user/kanshi.service @@ -0,0 +1,14 @@ +[Unit] +Description=Dynamic output configuration +Documentation=man:kanshi(1) +PartOf=wayland-session.target +Requires=wayland-session.target +After=wayland-session.target + +[Service] +Type=simple +ExecStart=/usr/bin/kanshi +Restart=always + +[Install] +WantedBy=wayland-session.target diff --git a/dot_config/systemd/user/sway-session-pre.target b/dot_config/systemd/user/sway-session-pre.target new file mode 100644 index 0000000..3215544 --- /dev/null +++ b/dot_config/systemd/user/sway-session-pre.target @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: LGPL-2.1+ +# +# This file is inspired from systemd's `graphical-session-pre.target` +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Session services which should run early before the sway session is brought up +Documentation=man:systemd.special(7) +Requires=basic.target +Before=sway-session.target +RefuseManualStart=yes +StopWhenUnneeded=yes +BindsTo=wayland-session-pre.target +After=wayland-session-pre.target diff --git a/dot_config/systemd/user/sway-session.target b/dot_config/systemd/user/sway-session.target index 56029b8..4637f0f 100644 --- a/dot_config/systemd/user/sway-session.target +++ b/dot_config/systemd/user/sway-session.target @@ -1,6 +1,18 @@ +# SPDX-License-Identifier: LGPL-2.1+ +# +# This file is inspired from systemd's `graphical-session.target` +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + [Unit] -Description=Sway session +Description=Current sway user session Documentation=man:systemd.special(7) -BindsTo=graphical-session.target -Wants=graphical-session-pre.target -After=graphical-session-pre.target +Requires=basic.target +#RefuseManualStart=yes +StopWhenUnneeded=yes +BindsTo=wayland-session.target +Wants=wayland-session-pre.target +After=wayland-session-pre.target diff --git a/dot_config/systemd/user/swaybg-random.service b/dot_config/systemd/user/swaybg-random.service index 37cd49d..06d7c29 100644 --- a/dot_config/systemd/user/swaybg-random.service +++ b/dot_config/systemd/user/swaybg-random.service @@ -1,12 +1,11 @@ [Unit] -Description=randomize background +Description=Randomize Wayland background [Service] Type=exec Restart=always RuntimeMaxSec=1h - ExecStart=/home/rak/bin/swaybg-random [Install] -WantedBy=default.target +WantedBy=wayland-session.target diff --git a/dot_config/systemd/user/swayidle.service b/dot_config/systemd/user/swayidle.service new file mode 100644 index 0000000..536eaf9 --- /dev/null +++ b/dot_config/systemd/user/swayidle.service @@ -0,0 +1,14 @@ +[Unit] +Description=Idle manager for Wayland +Documentation=man:swayidle(1) +PartOf=wayland-session.target +Requires=wayland-session.target +After=wayland-session.target + +[Service] +Type=simple +ExecStart=/usr/bin/swayidle -w +Restart=always + +[Install] +WantedBy=wayland-session.target diff --git a/dot_config/systemd/user/wayland-session-pre.target b/dot_config/systemd/user/wayland-session-pre.target new file mode 100644 index 0000000..e4057ed --- /dev/null +++ b/dot_config/systemd/user/wayland-session-pre.target @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: LGPL-2.1+ +# +# This file is inspired from systemd's `graphical-session-pre.target` +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Session services which should run early before the wayland session is brought up +Documentation=man:systemd.special(7) +Requires=basic.target +Before=wayland-session.target +RefuseManualStart=yes +StopWhenUnneeded=yes +BindsTo=graphical-session-pre.target +After=graphical-session-pre.target diff --git a/dot_config/systemd/user/wayland-session.target b/dot_config/systemd/user/wayland-session.target new file mode 100644 index 0000000..f4cc2b7 --- /dev/null +++ b/dot_config/systemd/user/wayland-session.target @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: LGPL-2.1+ +# +# This file is inspired from systemd's `graphical-session.target` +# +# systemd is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 2.1 of the License, or +# (at your option) any later version. + +[Unit] +Description=Current wayland user session +Documentation=man:systemd.special(7) +Requires=basic.target +RefuseManualStart=yes +StopWhenUnneeded=yes +BindsTo=graphical-session.target +Wants=graphical-session-pre.target +After=graphical-session-pre.target diff --git a/dot_config/systemd/user/wayland-session.target.wants/symlink_kanshi.service b/dot_config/systemd/user/wayland-session.target.wants/symlink_kanshi.service new file mode 100644 index 0000000..7d5903e --- /dev/null +++ b/dot_config/systemd/user/wayland-session.target.wants/symlink_kanshi.service @@ -0,0 +1 @@ +/home/rak/.config/systemd/user/kanshi.service diff --git a/dot_config/systemd/user/wayland-session.target.wants/symlink_swaybg-random.service b/dot_config/systemd/user/wayland-session.target.wants/symlink_swaybg-random.service new file mode 100644 index 0000000..2ebb1f9 --- /dev/null +++ b/dot_config/systemd/user/wayland-session.target.wants/symlink_swaybg-random.service @@ -0,0 +1 @@ +/home/rak/.config/systemd/user/swaybg-random.service diff --git a/dot_config/systemd/user/wayland-session.target.wants/symlink_swayidle.service b/dot_config/systemd/user/wayland-session.target.wants/symlink_swayidle.service new file mode 100644 index 0000000..a53991f --- /dev/null +++ b/dot_config/systemd/user/wayland-session.target.wants/symlink_swayidle.service @@ -0,0 +1 @@ +/home/rak/.config/systemd/user/swayidle.service -- cgit v1.2.3