# needed for torrenting
rtorrent
# needed for torrenting session
-tmux
+dtach
#
export EDITOR="${VISUAL}"
# Some helpful aliases.
-alias curlpost='curl -H "Content-Type: application/json" -X POST'
alias ls="ls --color=auto"
# Colored prompt with username, hostname, date/time, directory.
[Unit]
-Description=rtorrent in tmux session
+Description=rtorrent dtached
After=network.target
[Service]
-Type=forking
+Type=simple
User=plom
WorkingDirectory=/home/plom
-ExecStartPre=-/bin/rm -f /home/plom/session/rtorrent.lock
-ExecStart=/usr/bin/tmux new-session -d -s rtorrent_tmux /usr/bin/rtorrent
-ExecStop=/usr/bin/tmux kill-session -t rtorrent_tmux
-Restart=always
+ExecStart=/bin/sh -lc "rm -rf session/rtorrent.lock && dtach -n /tmp/dtach_rtorrent rtorrent && while true; do sleep 1; test ! -e /tmp/dtach_rtorrent && break; done"
+ExecStop=/bin/sh -lc kill_rtorrent
+Environment=TERM=linux
+Restart=on-success
RestartSec=10
[Install]
--- /dev/null
+alias attach_rtorrent='dtach -a /tmp/dtach_rtorrent -e "^t"'
--- /dev/null
+#!/bin/sh
+set -e
+
+PIDs=$(ps hao 'pid comm' | grep -E '^[[:blank:]]*[[:digit:]]+ rtorrent$' | sed -E 's/^[[:blank:]]+([[:digit:]]+).*$/\1/g')
+if [ ! -z "${PIDs}" ]; then
+ echo "Killing $(echo ${PIDs} | wc -w) instance(s)."
+ kill -9 "${PIDs}"
+else
+ echo 'Nothing to kill.'
+fi
+rm -rf /tmp/dtach_rtorrent
# a non-existing "en" layout
alias kb_de="swaymsg 'input * xkb_layout de'"
alias kb_us="swaymsg 'input * xkb_layout us'"
+
+# miscellaneaous
+alias curlpost='curl -H "Content-Type: application/json" -X POST'