summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-02-27 18:31:31 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-02-27 20:06:11 -0500
commit5e5e5029e76d88b3887bb175e28709a9022323a8 (patch)
treeeb77f3f626988f6592a6d51b2e08914f290b896b
parentc2ee55d77f093d7a5abf8118870900b866dbba52 (diff)
X11 systemd stuff
-rw-r--r--.config/X11/clientrc14
-rw-r--r--.config/X11/resources (renamed from .config/X11/defaults)0
-rw-r--r--.config/symlinks1
-rw-r--r--.config/systemd/user/X11@.target2
l---------.config/systemd/user/X11@.target.requires/wmii@.service (renamed from .config/systemd/user/wm@.target.requires/wmii@.service)0
-rw-r--r--.config/systemd/user/dunst@.service7
-rw-r--r--.config/systemd/user/emacs-daemon.service1
-rw-r--r--.config/systemd/user/lxpanel@.service8
-rw-r--r--.config/systemd/user/panel@.target4
-rw-r--r--.config/systemd/user/redshift@.service7
-rw-r--r--.config/systemd/user/synergy@.service8
-rw-r--r--.config/systemd/user/wm-running@.target2
l---------.config/systemd/user/wm-running@.target.requires/wmii@.service1
-rw-r--r--.config/systemd/user/wm@.target2
-rw-r--r--.config/systemd/user/wmii@.service10
-rw-r--r--.config/systemd/user/x0vncserver@.service5
-rw-r--r--.config/systemd/user/xcompmgr@.service6
-rw-r--r--.config/wmii-hg/config.sh13
-rw-r--r--.config/wmii-hg/include.sh3
-rw-r--r--.config/wmii-hg/rbar.sh4
-rwxr-xr-x.config/wmii-hg/term3
-rwxr-xr-x.config/wmii-hg/wmiirc4
-rw-r--r--.config/wmii-hg/workarounds.sh42
23 files changed, 113 insertions, 34 deletions
diff --git a/.config/X11/clientrc b/.config/X11/clientrc
index bc68ed6..e280f8d 100644
--- a/.config/X11/clientrc
+++ b/.config/X11/clientrc
@@ -17,14 +17,24 @@ if [ -f "$usermodmap" ]; then
xmodmap "$usermodmap"
fi
+dpi=$(LC_ALL=C DISPLAY=:0 xdpyinfo|sed -rn 's/^\s*resolution:\s*(.*) dots per inch$/\1/p')
+xrdb -merge <<<"Xft.dpi: ${dpi}"
+
+userresources="$XDG_CONFIG_HOME/X11/resources"
+if [ -f "$userresources" ]; then
+ xrdb -merge "$userresources"
+fi
+
if [ -z "$XDG_RUNTIME_DIR" ]; then
printf "XDG_RUNTIME_DIR isn't set\n" >&2
exit 6
fi
+
_DISPLAY="$(systemd-escape -- "$DISPLAY")"
trap "rm -f $(printf '%q' "${XDG_RUNTIME_DIR}/x11-wm@${_DISPLAY}")" EXIT
mkfifo "${XDG_RUNTIME_DIR}/x11-wm@${_DISPLAY}"
-cat "${XDG_RUNTIME_DIR}/x11-wm@${_DISPLAY}" &
-systemctl --user start "wm@${_DISPLAY}.target" &
+cat < "${XDG_RUNTIME_DIR}/x11-wm@${_DISPLAY}" &
+systemctl --user start "X11@${_DISPLAY}.target" &
wait
+systemctl --user stop "X11@${_DISPLAY}.target"
diff --git a/.config/X11/defaults b/.config/X11/resources
index fca1914..fca1914 100644
--- a/.config/X11/defaults
+++ b/.config/X11/resources
diff --git a/.config/symlinks b/.config/symlinks
index 209f291..8d92ec8 100644
--- a/.config/symlinks
+++ b/.config/symlinks
@@ -4,7 +4,6 @@
.config/login.sh .profile
# X11
-.config/X11/defaults .Xdefaults
.config/X11/clientrc .xinitrc
.config/X11/serverrc .xserverrc
.config/X11/login .xsession
diff --git a/.config/systemd/user/X11@.target b/.config/systemd/user/X11@.target
new file mode 100644
index 0000000..d84f814
--- /dev/null
+++ b/.config/systemd/user/X11@.target
@@ -0,0 +1,2 @@
+[Unit]
+Description=Connection to X11 display %I
diff --git a/.config/systemd/user/wm@.target.requires/wmii@.service b/.config/systemd/user/X11@.target.requires/wmii@.service
index 1b202d2..1b202d2 120000
--- a/.config/systemd/user/wm@.target.requires/wmii@.service
+++ b/.config/systemd/user/X11@.target.requires/wmii@.service
diff --git a/.config/systemd/user/dunst@.service b/.config/systemd/user/dunst@.service
index 568af3f..265845b 100644
--- a/.config/systemd/user/dunst@.service
+++ b/.config/systemd/user/dunst@.service
@@ -1,10 +1,11 @@
[Unit]
Description=Dunst notification-daemon on X display %I
Documentation=man:dunst(1)
-StopWhenUnneeded=true
+After=X11@%i.target
+Requisite=X11@%i.target
[Service]
-Type=simple
Environment=DISPLAY=%I
+
+Type=simple
ExecStart=/usr/bin/dunst
-Restart=always
diff --git a/.config/systemd/user/emacs-daemon.service b/.config/systemd/user/emacs-daemon.service
index 4077e97..eaf6729 100644
--- a/.config/systemd/user/emacs-daemon.service
+++ b/.config/systemd/user/emacs-daemon.service
@@ -5,6 +5,7 @@ Description=Emacs deamon
Type=forking
ExecStart=/bin/bash -l -c 'emacs --daemon'
ExecStop=/bin/bash -l -c 'emacsclient -a false -e "(kill-emacs)"'
+Restart=always
[Install]
WantedBy=default.target
diff --git a/.config/systemd/user/lxpanel@.service b/.config/systemd/user/lxpanel@.service
index ecded87..3a0dc67 100644
--- a/.config/systemd/user/lxpanel@.service
+++ b/.config/systemd/user/lxpanel@.service
@@ -2,14 +2,16 @@
Description=LXDE Desktop Panel on X display %I
Documentation=man:lxpanel(1)
StopWhenUnneeded=true
-After=wm@%i.target
+After=X11@%i.target wm-running@%i.target
+Requisite=X11@%i.target
+Requires=wm-running@%i.target
Before=panel@%i.target
[Service]
-Type=simple
Environment=DISPLAY=%I
+
+Type=simple
ExecStart=/usr/bin/lxpanel
-Restart=always
[Install]
RequiredBy=panel@%i.target
diff --git a/.config/systemd/user/panel@.target b/.config/systemd/user/panel@.target
index ed3dffd..53d45b0 100644
--- a/.config/systemd/user/panel@.target
+++ b/.config/systemd/user/panel@.target
@@ -1,3 +1,5 @@
[Unit]
-Description=Desktop Panel (System Tray) on display %I
+Description=Desktop Panel (System Tray) on X display %I
StopWhenUnneeded=true
+After=X11@%i.target
+Requisite=X11@%i.target
diff --git a/.config/systemd/user/redshift@.service b/.config/systemd/user/redshift@.service
index b4ef3bb..dff6e7b 100644
--- a/.config/systemd/user/redshift@.service
+++ b/.config/systemd/user/redshift@.service
@@ -1,11 +1,12 @@
[Unit]
Description=Redshift display colour temperature adjustment on X display %I
Documentation=http://jonls.dk/redshift/
-StopWhenUnneeded=true
+After=X11@%i.target
+Requisite=X11@%i.target
[Service]
-Type=simple
Environment=DISPLAY=%I
+
+Type=simple
ExecStart=/usr/bin/redshift
ExecStopPost=/usr/bin/redshift -x
-Restart=always
diff --git a/.config/systemd/user/synergy@.service b/.config/systemd/user/synergy@.service
index df0640a..dc15e58 100644
--- a/.config/systemd/user/synergy@.service
+++ b/.config/systemd/user/synergy@.service
@@ -1,10 +1,12 @@
[Unit]
Description=Keyboard and mouse sharing on X display %I
-StopWhenUnneeded=true
+#StopWhenUnneeded=true
+After=X11@%i.target panel@%i.target
+Requisite=X11@%i.target
Requires=panel@%i.target
[Service]
-Type=simple
Environment=DISPLAY=%I
+
+Type=simple
ExecStart=/usr/bin/synergy
-Restart=always
diff --git a/.config/systemd/user/wm-running@.target b/.config/systemd/user/wm-running@.target
new file mode 100644
index 0000000..8d3a38b
--- /dev/null
+++ b/.config/systemd/user/wm-running@.target
@@ -0,0 +1,2 @@
+[Unit]
+Description=Window Manager is running on X display %I
diff --git a/.config/systemd/user/wm-running@.target.requires/wmii@.service b/.config/systemd/user/wm-running@.target.requires/wmii@.service
new file mode 120000
index 0000000..1b202d2
--- /dev/null
+++ b/.config/systemd/user/wm-running@.target.requires/wmii@.service
@@ -0,0 +1 @@
+../wmii@.service \ No newline at end of file
diff --git a/.config/systemd/user/wm@.target b/.config/systemd/user/wm@.target
deleted file mode 100644
index c114bf5..0000000
--- a/.config/systemd/user/wm@.target
+++ /dev/null
@@ -1,2 +0,0 @@
-[Unit]
-Description=Window Manager on display %I
diff --git a/.config/systemd/user/wmii@.service b/.config/systemd/user/wmii@.service
index 4a81e3f..f1e87df 100644
--- a/.config/systemd/user/wmii@.service
+++ b/.config/systemd/user/wmii@.service
@@ -1,17 +1,19 @@
[Unit]
Description=Window Manager Improved Improved on X display %I
Documentation=file:/usr/share/doc/wmii/wmii.pdf
-Before=wm@%i.target
-StopWhenUnneeded=true
+After=X11@%i.target
+Requisite=X11@%i.target
+Before=wm-running@%i.target
[Service]
+Environment=DISPLAY=%I
+
# 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'
ExecStop=/usr/bin/wmiir xwrite /ctl Quit
[Install]
-RequiredBy=wm@%i.service
+RequiredBy=X11@%i.target
diff --git a/.config/systemd/user/x0vncserver@.service b/.config/systemd/user/x0vncserver@.service
index 3ee349f..4a995f6 100644
--- a/.config/systemd/user/x0vncserver@.service
+++ b/.config/systemd/user/x0vncserver@.service
@@ -1,9 +1,10 @@
[Unit]
Description=VNC server for real X display %I
Conflicts=vncserver@%i.service
-StopWhenUnneeded=true
+After=X11@%i.target
+Requisite=X11@%i.target
[Service]
+
Type=simple
ExecStart=/usr/bin/x0vncserver display=%I PasswordFile=%h/.vnc/passwd
-Restart=always
diff --git a/.config/systemd/user/xcompmgr@.service b/.config/systemd/user/xcompmgr@.service
index 85decd2..6d80218 100644
--- a/.config/systemd/user/xcompmgr@.service
+++ b/.config/systemd/user/xcompmgr@.service
@@ -2,9 +2,11 @@
Description=Composite Window-Effects Manger on X display %I
Documentation=man:xcompmgr(1)
StopWhenUnneeded=true
+After=X11@%i.target
+Requisite=X11@%i.target
[Service]
-Type=simple
Environment=DISPLAY=%I
+
+Type=simple
ExecStart=/usr/bin/xcompmgr
-Restart=always
diff --git a/.config/wmii-hg/config.sh b/.config/wmii-hg/config.sh
index 4b968b0..77d813f 100644
--- a/.config/wmii-hg/config.sh
+++ b/.config/wmii-hg/config.sh
@@ -229,9 +229,9 @@ Key() {
$MODKEY-x) ## Open program menu
local command
command="$(path_ls "$_PATH" | wimenu -h "${HIST}.progs" -n 5000)" || return
- ( PATH=$_PATH; unset _PATH NOTIFY_SOCKET; exec $command ) & ;;
+ runcmd "$command" & ;;
$MODKEY-Return) ## Launch a terminal
- ( PATH=$_PATH; unset _PATH NOTIFY_SOCKET; exec x-terminal-emulator ) & ;;
+ runcmd x-terminal-emulator & ;;
## Tag actions
$MODKEY-t) ## Change to another tag
@@ -246,6 +246,15 @@ Key() {
esac
}
+runcmd() (
+ PATH=$_PATH
+ unset NOTIFY_SOCKET # systemd
+ unset WMII_CONFPATH # wmii
+ unset _PATH WMII_NAMESPACE WMII_DIR # wmiirc
+ exec 8>&- # xinit/systemd handshake
+ exec systemd-run --user --scope -- sh -c "$*"
+)
+
Action() {
local prog=$(path_which "$WMII_CONFPATH" "$1"); shift
if [ -n "$prog" ]; then
diff --git a/.config/wmii-hg/include.sh b/.config/wmii-hg/include.sh
index f8c4e0d..788e2af 100644
--- a/.config/wmii-hg/include.sh
+++ b/.config/wmii-hg/include.sh
@@ -8,8 +8,9 @@ if [[ -z "$WMII_NAMESPACE" ]]; then
export WMII_NAMESPACE="$(wmiir namespace)"
fi
if [[ -z "$WMII_DIR" ]]; then
- export WMII_DIR="${XDG_RUNTIME_DIR}/n/wmii${DISPLAY}"
+ export WMII_DIR="${XDG_RUNTIME_DIR}/wmii${DISPLAY}"
fi
+. workarounds.sh
. util.sh
. config.sh
diff --git a/.config/wmii-hg/rbar.sh b/.config/wmii-hg/rbar.sh
index 287f427..cf256dd 100644
--- a/.config/wmii-hg/rbar.sh
+++ b/.config/wmii-hg/rbar.sh
@@ -5,11 +5,11 @@ if [[ -z "$XDG_RUNTIME_DIR" ]]; then
fi
setup_trap() {
- trap "rm -f -- \"\${XDG_RUNTIME_DIR}\"/n/wmii*/rbar/${1}" EXIT
+ trap "rm -f -- \"\${XDG_RUNTIME_DIR}\"/wmii*/rbar/${1}" EXIT
}
write() {
- local dirs=("${XDG_RUNTIME_DIR}"/n/wmii*/rbar/)
+ local dirs=("${XDG_RUNTIME_DIR}"/wmii*/rbar/)
sponge|tee -a "${dirs[@]/%/${1}}" > /dev/null
}
diff --git a/.config/wmii-hg/term b/.config/wmii-hg/term
new file mode 100755
index 0000000..4ba9d29
--- /dev/null
+++ b/.config/wmii-hg/term
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+. include.sh
+exec urxvt \ No newline at end of file
diff --git a/.config/wmii-hg/wmiirc b/.config/wmii-hg/wmiirc
index 379de79..a66d3d9 100755
--- a/.config/wmii-hg/wmiirc
+++ b/.config/wmii-hg/wmiirc
@@ -12,9 +12,7 @@ fi
wmiir xwrite /event WmiircQuit # close any existing wmiirc's
Event WmiircStart
-# Notify systemd that we're ready
-systemd-notify READY=1 || true
-
+systemd-notify --ready || true
trap "Event Quit" EXIT
while read -r event; do
diff --git a/.config/wmii-hg/workarounds.sh b/.config/wmii-hg/workarounds.sh
new file mode 100644
index 0000000..b3d50fe
--- /dev/null
+++ b/.config/wmii-hg/workarounds.sh
@@ -0,0 +1,42 @@
+#!/hint/bash
+
+##
+# Just like systemd-notify(1), but slower, which is a shitty
+# workaround for a race condition in systemd.
+##
+systemd-notify() {
+ local args
+ args="$(getopt -n systemd-notify -o h -l help,version,ready,pid::,status:,booted -- "$@")"
+ ret=$?; [[ $ret == 0 ]] || return $ret
+ eval set -- "$args"
+
+ local arg_ready=false
+ local arg_pid=0
+ local arg_status=
+ while [[ $# -gt 0 ]]; do
+ case "$1" in
+ -h|--help) command systemd-notify --help; return $?;;
+ --version) command systemd-notify --version; return $?;;
+ --ready) arg_ready=true; shift 1;;
+ --pid) arg_pid=${2:-$$}; shift 2;;
+ --status) arg_status=$2; shift 2;;
+ --booted) command systemd-notify --booted; return $?;;
+ --) shift 1; break;;
+ esac
+ done
+
+ local our_env=()
+ if $arg_ready; then
+ our_env+=("READY=1")
+ fi
+ if [[ -n "$arg_status" ]]; then
+ our_env+=("STATUS=$arg_status")
+ fi
+ if [[ "$arg_pid" -gt 0 ]]; then
+ our_env+=("MAINPID=$arg_pid")
+ fi
+ our_env+=("$@")
+ local n
+ printf -v n '%s\n' "${our_env[@]}"
+ socat STDIO UNIX-SENDTO:"$NOTIFY_SOCKET" <<<"$n"
+}