From 7fa8100ee556f0c94adfb91a240001ce86104c48 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 4 Feb 2015 15:13:00 -0500 Subject: systemd: Add and use wm@$DISPLAY.target wm@.target to change the default window manager. Create wm@$DISPLAY to override for a particular display --- .config/X11/clientrc | 10 +++++----- .config/systemd/user/lxpanel@.service | 1 + .config/systemd/user/wm@.target | 3 +++ .config/systemd/user/wmii@.service | 7 +++++-- .config/systemd/user/x0vncserver@.service | 1 + .config/wmii-hg/config.sh | 8 +++++--- .config/wmii-hg/quit | 8 ++++++-- .config/wmii-hg/wmiirc | 4 ++++ 8 files changed, 30 insertions(+), 12 deletions(-) create mode 100644 .config/systemd/user/wm@.target diff --git a/.config/X11/clientrc b/.config/X11/clientrc index 9488ec8..4773ea4 100755 --- a/.config/X11/clientrc +++ b/.config/X11/clientrc @@ -17,9 +17,9 @@ if [ -f "$usermodmap" ]; then xmodmap "$usermodmap" fi -#exec wmii -wm=wmii +trap "rm -f $(printf '%q' "${XDG_RUNTIME_DIR}/x11-wm@${DISPLAY}")" EXIT mkfifo "${XDG_RUNTIME_DIR}/x11-wm@${DISPLAY}" -trap "rm $(printf %q "${XDG_RUNTIME_DIR}/x11-wm@${DISPLAY}")" EXIT -systemctl --user start "${wm}@${DISPLAY}.service" -cat "${XDG_RUNTIME_DIR}/x11-wm@${DISPLAY}" >/dev/null + +cat "${XDG_RUNTIME_DIR}/x11-wm@${DISPLAY}" & +systemctl --user start "wm@${DISPLAY}.target" & +wait diff --git a/.config/systemd/user/lxpanel@.service b/.config/systemd/user/lxpanel@.service index 3327ab4..fa4dcb4 100644 --- a/.config/systemd/user/lxpanel@.service +++ b/.config/systemd/user/lxpanel@.service @@ -2,6 +2,7 @@ Description=LXDE Desktop Panel Documentation=man:lxpanel(1) StopWhenUnneeded=true +After=wm@%i.target [Service] Type=simple diff --git a/.config/systemd/user/wm@.target b/.config/systemd/user/wm@.target new file mode 100644 index 0000000..ac91fa1 --- /dev/null +++ b/.config/systemd/user/wm@.target @@ -0,0 +1,3 @@ +[Unit] +Description=Window Manager on display %I +Requires=wmii@%i.service diff --git a/.config/systemd/user/wmii@.service b/.config/systemd/user/wmii@.service index 3902627..602bdb8 100644 --- a/.config/systemd/user/wmii@.service +++ b/.config/systemd/user/wmii@.service @@ -1,10 +1,13 @@ [Unit] Description=Window Manager Improved Improved Documentation=file:/usr/share/doc/wmii/wmii.pdf +Before=wm@%i.target +StopWhenUnneeded=true [Service] -Type=simple -Restart=no +# This assumes that you write READY=1 to $NOTIFY_SOCKET in wmiirc +Type=notify +NotifyAccess=all Environment=DISPLAY=%I ExecStart=/usr/bin/bash -l -c 'exec 8>${XDG_RUNTIME_DIR}/x11-wm@%I; exec /usr/bin/wmii' diff --git a/.config/systemd/user/x0vncserver@.service b/.config/systemd/user/x0vncserver@.service index 02165a7..21a3b7b 100644 --- a/.config/systemd/user/x0vncserver@.service +++ b/.config/systemd/user/x0vncserver@.service @@ -1,6 +1,7 @@ [Unit] Description=VNC server for X displays Conflicts=vncserver@%i.service +StopWhenUnneeded=true [Service] Type=simple diff --git a/.config/wmii-hg/config.sh b/.config/wmii-hg/config.sh index ad4d2fe..64596a8 100644 --- a/.config/wmii-hg/config.sh +++ b/.config/wmii-hg/config.sh @@ -66,8 +66,10 @@ Event() { rmdir -p "$WMII_DIR" 2>/dev/null;; ## WMII-meta events Quit) ## No args - echo ' ==> wmii quit: unmounting' trap - EXIT + if [ -S "$NOTIFY_SOCKET" ]; then + echo STOPPING=1 | socat STDIO UNIX-SENDTO:"$NOTIFY_SOCKET" + fi Event WmiircUnmount Event WmiircQuit;; Warning) ## $@=string @@ -228,9 +230,9 @@ Key() { $MODKEY-x) ## Open program menu local command command="$(path_ls "$_PATH" | wimenu -h "${HIST}.progs" -n 5000)" || return - ( PATH=$_PATH; unset _PATH; exec $command ) & ;; + ( PATH=$_PATH; unset _PATH NOTIFY_SOCKET; exec $command ) & ;; $MODKEY-Return) ## Launch a terminal - ( PATH=$_PATH; unset _PATH; exec x-terminal-emulator ) & ;; + ( PATH=$_PATH; unset _PATH NOTIFY_SOCKET; exec x-terminal-emulator ) & ;; ## Tag actions $MODKEY-t) ## Change to another tag diff --git a/.config/wmii-hg/quit b/.config/wmii-hg/quit index 27d9052..341468e 100755 --- a/.config/wmii-hg/quit +++ b/.config/wmii-hg/quit @@ -1,3 +1,7 @@ #!/bin/bash -. include.sh -echo quit >> $WMII_DIR/ctl +if type systemctl &>/dev/null; then + systemctl --user stop "wmii@$DISPLAY.service" +else + . include.sh + echo quit >> $WMII_DIR/ctl +fi diff --git a/.config/wmii-hg/wmiirc b/.config/wmii-hg/wmiirc index 396bed2..6fd348f 100755 --- a/.config/wmii-hg/wmiirc +++ b/.config/wmii-hg/wmiirc @@ -12,6 +12,10 @@ fi wmiir xwrite /event WmiircQuit # close any existing wmiirc's Event WmiircStart +# Notify systemd that we're ready +if [ -S "$NOTIFY_SOCKET" ]; then + echo READY=1 | socat STDIO UNIX-SENDTO:"$NOTIFY_SOCKET" +fi trap "Event Quit" EXIT -- cgit v1.2.3