From 85925bd2fe2bfacf73a371274da454290387be60 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 29 Jul 2022 01:45:59 +1200 Subject: Add tmux server systemd server method --- .gitignore | 1 + Makefile | 10 +++++++++- tmux/bin/tmux.sh | 11 +++++++++++ tmux/profile.d/tmux.sh | 3 +++ tmux/systemd/user/tmux.service | 11 +++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 tmux/bin/tmux.sh create mode 100644 tmux/profile.d/tmux.sh create mode 100644 tmux/systemd/user/tmux.service 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 -- cgit v1.2.3