aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2022-07-29 01:45:59 +1200
committerTom Ryder <tom@sanctum.geek.nz>2022-07-29 01:47:51 +1200
commit85925bd2fe2bfacf73a371274da454290387be60 (patch)
treecfcd6243623d443a5edc57d188eb9bcdcf453d77
parentMerge branch 'release/v12.12.0' into develop (diff)
downloaddotfiles-85925bd2fe2bfacf73a371274da454290387be60.tar.gz
dotfiles-85925bd2fe2bfacf73a371274da454290387be60.zip
Add tmux server systemd server method
-rw-r--r--.gitignore1
-rw-r--r--Makefile10
-rw-r--r--tmux/bin/tmux.sh11
-rw-r--r--tmux/profile.d/tmux.sh3
-rw-r--r--tmux/systemd/user/tmux.service11
5 files changed, 35 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index d5431855..107c89da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -186,5 +186,6 @@
/include/mktd.m4
/less/less
/mutt/filters/markdown-to-html
+/tmux/bin/tmux
/urxvt/ext/select
/x/xsession
diff --git a/Makefile b/Makefile
index 1f6ccd12..f5f24446 100644
--- a/Makefile
+++ b/Makefile
@@ -280,6 +280,7 @@ all: $(BINS) \
git/config \
gnupg/profile.d/gnupg.sh \
less/less \
+ tmux/bin/tmux \
x/xsession
clean distclean:
@@ -298,6 +299,7 @@ clean distclean:
include/mktd.m4 \
less/less \
mutt/filters/markdown-to-html \
+ tmux/bin/tmux \
urxvt/ext/select \
x/xsession
@@ -624,8 +626,14 @@ install-tidy: install-sh
mkdir -p -- $(XDG_CONFIG_HOME)/tidy
cp -p -- tidy/tidyrc $(XDG_CONFIG_HOME)/tidy/tidyrc
-install-tmux: tmux/tmux.conf install-terminfo
+install-tmux: tmux/bin/tmux tmux/tmux.conf install-systemd install-terminfo
+ cp -p -- tmux/bin/tmux $(HOME)/.local/bin
+ cp -p -- tmux/profile.d/tmux.sh $(HOME)/.profile.d
cp -p -- tmux/tmux.conf $(HOME)/.tmux.conf
+ cp -p -- tmux/systemd/user/tmux.service \
+ $(XDG_DATA_HOME)/systemd/user
+ -systemctl --user enable tmux.service
+ -systemctl --user start tmux.service
install-urxvt: urxvt/ext/select install-x
mkdir -p -- $(HOME)/.urxvt/ext
diff --git a/tmux/bin/tmux.sh b/tmux/bin/tmux.sh
new file mode 100644
index 00000000..bbe11636
--- /dev/null
+++ b/tmux/bin/tmux.sh
@@ -0,0 +1,11 @@
+#
+# Simple wrapper to force acting only as client; can't do anything if the
+# server isn't actually running. The correct way to do this is of course
+# socket activation, but Debian's version doesn't have --enable-systemd yet.
+# This will do fine in the meantime.
+#
+if ! systemctl --user is-active --quiet tmux.service ; then
+ printf >&2 'tmux: server not running\n'
+ exit
+fi
+exec /usr/bin/tmux "$@"
diff --git a/tmux/profile.d/tmux.sh b/tmux/profile.d/tmux.sh
new file mode 100644
index 00000000..2a936da5
--- /dev/null
+++ b/tmux/profile.d/tmux.sh
@@ -0,0 +1,3 @@
+# Encourage tmux to put its sockets into XDG_RUNTIME_DIR rather than /tmp
+[ -n "$XDG_RUNTIME_DIR" ] || return
+export TMUX_TMPDIR=$XDG_RUNTIME_DIR
diff --git a/tmux/systemd/user/tmux.service b/tmux/systemd/user/tmux.service
new file mode 100644
index 00000000..404f1888
--- /dev/null
+++ b/tmux/systemd/user/tmux.service
@@ -0,0 +1,11 @@
+[Unit]
+Description=tmux server
+Documentation=man:tmux(1)
+
+[Service]
+ExecStart=/bin/sh -lc 'exec /usr/bin/tmux start-server \\; set-option -s exit-empty off'
+KillMode=mixed
+Type=forking
+
+[Install]
+WantedBy=default.target