From 5200bb4e39193a500a86267c70d34aea98b2a653 Mon Sep 17 00:00:00 2001
From: Patrick Spek
Date: Fri, 16 Feb 2024 10:57:51 +0100
Subject: Yet another rework of systemd-managed window management
---
.config/awesome/rc.lua | 8 --------
.config/systemd/user/bscv-dunst.service | 19 +++++++++++++++++++
.config/systemd/user/bscv-ntfy@.service | 15 +++++++++++++++
.config/systemd/user/bscv-sxhkd.service | 19 +++++++++++++++++++
.config/systemd/user/desktop-app@.service | 18 ------------------
.config/systemd/user/desktop-x11.target | 2 --
.config/systemd/user/desktop.target | 2 --
.config/systemd/user/fsvc-firefox.service | 18 ++++++++++++++++++
.config/systemd/user/fsvc-irc.service | 18 ++++++++++++++++++
.config/systemd/user/fsvc-nm-applet.service | 18 ++++++++++++++++++
.config/systemd/user/ntfy@.service | 15 ---------------
.config/systemd/user/wman-awesome.service | 19 +++++++++++++++++++
.config/systemd/user/wman.target | 2 ++
.config/systemd/user/wsys-xorg.service | 25 +++++++++++++++++++++++++
.config/systemd/user/wsys-xorg.socket | 5 +++++
.config/systemd/user/wsys-xorg.target | 3 +++
.config/systemd/user/wsys.target | 2 ++
17 files changed, 163 insertions(+), 45 deletions(-)
create mode 100644 .config/systemd/user/bscv-dunst.service
create mode 100644 .config/systemd/user/bscv-ntfy@.service
create mode 100644 .config/systemd/user/bscv-sxhkd.service
delete mode 100644 .config/systemd/user/desktop-app@.service
delete mode 100644 .config/systemd/user/desktop-x11.target
delete mode 100644 .config/systemd/user/desktop.target
create mode 100644 .config/systemd/user/fsvc-firefox.service
create mode 100644 .config/systemd/user/fsvc-irc.service
create mode 100644 .config/systemd/user/fsvc-nm-applet.service
delete mode 100644 .config/systemd/user/ntfy@.service
create mode 100644 .config/systemd/user/wman-awesome.service
create mode 100644 .config/systemd/user/wman.target
create mode 100644 .config/systemd/user/wsys-xorg.service
create mode 100644 .config/systemd/user/wsys-xorg.socket
create mode 100644 .config/systemd/user/wsys-xorg.target
create mode 100644 .config/systemd/user/wsys.target
diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua
index ad20842..2c9eebc 100644
--- a/.config/awesome/rc.lua
+++ b/.config/awesome/rc.lua
@@ -46,14 +46,6 @@ do
end
-- }}}
--- Start the desktop.target to autostart applications through systemd
-awful.util.spawn_with_shell("systemctl --user import-environment DISPLAY")
-awful.util.spawn_with_shell("systemctl --user import-environment PATH")
-awful.util.spawn_with_shell("systemctl --user import-environment WINIT_X11_SCALE_FACTOR")
-awful.util.spawn_with_shell("systemctl --user import-environment XAUTHORITY")
-awful.util.spawn_with_shell("systemctl --user start desktop.target")
-awful.util.spawn_with_shell("systemctl --user start desktop-x11.target")
-
-- {{{ Variable definitions
beautiful.init(awful.util.getdir("config") .. "/theme.lua")
diff --git a/.config/systemd/user/bscv-dunst.service b/.config/systemd/user/bscv-dunst.service
new file mode 100644
index 0000000..ac64078
--- /dev/null
+++ b/.config/systemd/user/bscv-dunst.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Manage an x11 application
+PartOf=graphical-session.target
+After=wman.target
+
+[Service]
+Type=exec
+Restart=on-failure
+
+ExecSearchPath=%h/.local/bin
+ExecSearchPath=/usr/local/bin
+ExecSearchPath=/usr/bin
+Environment=PATH=/home/tyil/.local/bin:/home/tyil/.config/shell/wrappers.d:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
+WorkingDirectory=%h
+
+ExecStart=/usr/bin/dunst
+
+[Install]
+WantedBy=wman.target
diff --git a/.config/systemd/user/bscv-ntfy@.service b/.config/systemd/user/bscv-ntfy@.service
new file mode 100644
index 0000000..0490ea1
--- /dev/null
+++ b/.config/systemd/user/bscv-ntfy@.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Start ntfy
+After=network.target
+After=wman.target
+
+[Service]
+Type=exec
+ExecSearchPath=%h/.local/bin
+ExecSearchPath=/usr/local/bin
+ExecSearchPath=/usr/bin
+ExecStart=ntfy subscribe "%i" 'notify-send "$t" "$m"'
+Restart=on-failure
+
+[Install]
+WantedBy=wman.target
diff --git a/.config/systemd/user/bscv-sxhkd.service b/.config/systemd/user/bscv-sxhkd.service
new file mode 100644
index 0000000..f1dde07
--- /dev/null
+++ b/.config/systemd/user/bscv-sxhkd.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Manage an x11 application
+PartOf=graphical-session.target
+After=wman.target
+
+[Service]
+Type=exec
+Restart=on-failure
+
+ExecSearchPath=%h/.local/bin
+ExecSearchPath=/usr/local/bin
+ExecSearchPath=/usr/bin
+Environment=PATH=/home/tyil/.local/bin:/home/tyil/.config/shell/wrappers.d:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
+WorkingDirectory=%h
+
+ExecStart=/usr/bin/sxhkd
+
+[Install]
+WantedBy=wman.target
diff --git a/.config/systemd/user/desktop-app@.service b/.config/systemd/user/desktop-app@.service
deleted file mode 100644
index e2f0281..0000000
--- a/.config/systemd/user/desktop-app@.service
+++ /dev/null
@@ -1,18 +0,0 @@
-[Unit]
-Description=Manage an x11 application
-PartOf=graphical-session.target
-
-[Service]
-Type=exec
-Restart=on-failure
-
-ExecSearchPath=%h/.local/bin
-ExecSearchPath=/usr/local/bin
-ExecSearchPath=/usr/bin
-Environment=PATH=/home/tyil/.local/bin:/home/tyil/.config/shell/wrappers.d:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
-WorkingDirectory=%h
-
-ExecStart=%i
-
-[Install]
-WantedBy=desktop.target
diff --git a/.config/systemd/user/desktop-x11.target b/.config/systemd/user/desktop-x11.target
deleted file mode 100644
index 5d7d771..0000000
--- a/.config/systemd/user/desktop-x11.target
+++ /dev/null
@@ -1,2 +0,0 @@
-[Unit]
-Description = Target to be reached when the graphical desktop environment has started
diff --git a/.config/systemd/user/desktop.target b/.config/systemd/user/desktop.target
deleted file mode 100644
index 5d7d771..0000000
--- a/.config/systemd/user/desktop.target
+++ /dev/null
@@ -1,2 +0,0 @@
-[Unit]
-Description = Target to be reached when the graphical desktop environment has started
diff --git a/.config/systemd/user/fsvc-firefox.service b/.config/systemd/user/fsvc-firefox.service
new file mode 100644
index 0000000..10e72a3
--- /dev/null
+++ b/.config/systemd/user/fsvc-firefox.service
@@ -0,0 +1,18 @@
+[Unit]
+Description=Manage an x11 application
+PartOf=graphical-session.target
+
+[Service]
+Type=exec
+Restart=on-failure
+
+ExecSearchPath=%h/.local/bin
+ExecSearchPath=/usr/local/bin
+ExecSearchPath=/usr/bin
+Environment=PATH=/home/tyil/.local/bin:/home/tyil/.config/shell/wrappers.d:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
+WorkingDirectory=%h
+
+ExecStart=firefox
+
+[Install]
+WantedBy=wman.target
diff --git a/.config/systemd/user/fsvc-irc.service b/.config/systemd/user/fsvc-irc.service
new file mode 100644
index 0000000..efd4b81
--- /dev/null
+++ b/.config/systemd/user/fsvc-irc.service
@@ -0,0 +1,18 @@
+[Unit]
+Description=Manage an x11 application
+PartOf=graphical-session.target
+
+[Service]
+Type=exec
+Restart=on-failure
+
+ExecSearchPath=%h/.local/bin
+ExecSearchPath=/usr/local/bin
+ExecSearchPath=/usr/bin
+Environment=PATH=/home/tyil/.local/bin:/home/tyil/.config/shell/wrappers.d:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
+WorkingDirectory=%h
+
+ExecStart=irc
+
+[Install]
+WantedBy=wman.target
diff --git a/.config/systemd/user/fsvc-nm-applet.service b/.config/systemd/user/fsvc-nm-applet.service
new file mode 100644
index 0000000..54cbd9e
--- /dev/null
+++ b/.config/systemd/user/fsvc-nm-applet.service
@@ -0,0 +1,18 @@
+[Unit]
+Description=Manage an x11 application
+PartOf=graphical-session.target
+
+[Service]
+Type=exec
+Restart=on-failure
+
+ExecSearchPath=%h/.local/bin
+ExecSearchPath=/usr/local/bin
+ExecSearchPath=/usr/bin
+Environment=PATH=/home/tyil/.local/bin:/home/tyil/.config/shell/wrappers.d:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin
+WorkingDirectory=%h
+
+ExecStart=nm-applet
+
+[Install]
+WantedBy=wman.target
diff --git a/.config/systemd/user/ntfy@.service b/.config/systemd/user/ntfy@.service
deleted file mode 100644
index 6f2587b..0000000
--- a/.config/systemd/user/ntfy@.service
+++ /dev/null
@@ -1,15 +0,0 @@
-[Unit]
-Description=Start ntfy
-PartOf=graphical-session.target
-After=network.target
-
-[Service]
-Type=exec
-ExecSearchPath=%h/.local/bin
-ExecSearchPath=/usr/local/bin
-ExecSearchPath=/usr/bin
-ExecStart=ntfy subscribe "%i" 'notify-send "$t" "$m"'
-Restart=on-failure
-
-[Install]
-WantedBy=desktop.target
diff --git a/.config/systemd/user/wman-awesome.service b/.config/systemd/user/wman-awesome.service
new file mode 100644
index 0000000..3b093c9
--- /dev/null
+++ b/.config/systemd/user/wman-awesome.service
@@ -0,0 +1,19 @@
+[Unit]
+Description=Awesome window manager
+Requires=wsys-xorg.service
+
+After=wsys-xorg.target
+Before=wman.target
+
+[Service]
+Environment=XAUTHORITY=%h/.Xauthority
+Environment=DISPLAY=:1
+Restart=always
+
+ExecStart=/usr/bin/awesome
+ExecStartPost=systemctl --user --no-block start wman.target
+
+ExecStopPre=systemctl --user --no-block stop wman.target
+
+[Install]
+WantedBy=wsys.target
diff --git a/.config/systemd/user/wman.target b/.config/systemd/user/wman.target
new file mode 100644
index 0000000..b7b343b
--- /dev/null
+++ b/.config/systemd/user/wman.target
@@ -0,0 +1,2 @@
+[Unit]
+Description = Window Manager
diff --git a/.config/systemd/user/wsys-xorg.service b/.config/systemd/user/wsys-xorg.service
new file mode 100644
index 0000000..a1784ed
--- /dev/null
+++ b/.config/systemd/user/wsys-xorg.service
@@ -0,0 +1,25 @@
+# Ensure you are allowed to run X.org as a regular non-console user!
+
+# /etc/X11/Xwrapper.conf
+# allowed_users=anybody
+# needs_root_rights=yes
+
+[Unit]
+Description=Xorg server at display :1
+
+Requires=wsys-xorg.socket
+After=wsys-xorg.socket
+Before=wsys.target
+
+[Service]
+Type=simple
+SuccessExitStatus=0 1
+
+ExecStart=/usr/bin/Xorg :1 -nolisten tcp -noreset -verbose 2 "vt1"
+ExecStartPost=systemctl --user import-environment DISPLAY
+ExecStartPost=systemctl --user import-environment XAUTHORITY
+ExecStartPost=systemctl --user --no-block start wsys-xorg.target
+ExecStartPost=systemctl --user --no-block start wsys.target
+
+ExecStopPre=systemctl --user stop wsys.target
+ExecStopPre=systemctl --user stop wsys-xorg.target
diff --git a/.config/systemd/user/wsys-xorg.socket b/.config/systemd/user/wsys-xorg.socket
new file mode 100644
index 0000000..f471dab
--- /dev/null
+++ b/.config/systemd/user/wsys-xorg.socket
@@ -0,0 +1,5 @@
+[Unit]
+Description=Socket for xorg at display :1
+
+[Socket]
+ListenStream=/tmp/.X11-unix/X1
diff --git a/.config/systemd/user/wsys-xorg.target b/.config/systemd/user/wsys-xorg.target
new file mode 100644
index 0000000..248722e
--- /dev/null
+++ b/.config/systemd/user/wsys-xorg.target
@@ -0,0 +1,3 @@
+[Unit]
+Before = wsys.target
+Description = Window System managed by X.org
diff --git a/.config/systemd/user/wsys.target b/.config/systemd/user/wsys.target
new file mode 100644
index 0000000..60a9c9f
--- /dev/null
+++ b/.config/systemd/user/wsys.target
@@ -0,0 +1,2 @@
+[Unit]
+Description = Window System
--
cgit v1.1