summaryrefslogtreecommitdiff
path: root/irssi.service
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2020-04-08 22:21:32 -0700
committerMatt Turner <mattst88@gmail.com>2020-04-08 22:21:32 -0700
commit414b067f8e3f7daeefda0462934ec36d4f128310 (patch)
tree77c30ad75a0092dd6834092255227101416972d7 /irssi.service
Initial import
Diffstat (limited to 'irssi.service')
-rw-r--r--irssi.service26
1 files changed, 26 insertions, 0 deletions
diff --git a/irssi.service b/irssi.service
new file mode 100644
index 0000000..58a9165
--- /dev/null
+++ b/irssi.service
@@ -0,0 +1,26 @@
+[Unit]
+Description=irssi (in tmux)
+Documentation=man:irssi(1)
+Requires=nss-lookup.target
+Wants=network-online.target
+After=network-online.target nss-lookup.target
+
+[Service]
+Type=forking
+TimeoutSec=5
+WorkingDirectory=~
+Environment=WIDTH=80 HEIGHT=24
+EnvironmentFile=-%E/tmux-irssi.env
+ExecStart=/bin/sh -c '/usr/bin/tmux -L %p -2 new-session -A -d -x ${WIDTH} -y ${HEIGHT} -s irssi /usr/bin/irssi'
+
+# Send CTRL+u to clear the input line before /quit
+ExecStop=-/usr/bin/tmux -L %p send-keys -t irssi:0 C-u
+ExecStop=-/usr/bin/tmux -L %p send-keys -t irssi:0 "/quit" Enter
+
+# Sending /quit to irssi is asynchronous, so wait for irssi to exit
+# before killing the session in tmux
+ExecStop=/bin/sh -c '/usr/bin/timeout 3 /usr/bin/tail --pid=$(/bin/cat %t/irssi.pid || echo 0) -f /dev/null'
+ExecStop=-/usr/bin/tmux -L %p kill-session -t irssi
+
+[Install]
+WantedBy=default.target