summaryrefslogtreecommitdiff
path: root/archive/bin/rt
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-11-23 23:35:59 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-11-24 12:42:27 -0700
commitc67d4836f4d6d5e6c8ef4e2de38bd21ccb6ee1a1 (patch)
treefded906652b6bf03c60e0c133a368c5027cd4d1e /archive/bin/rt
parentaa5a315a0876431105f73da75de9ddfa89e907d3 (diff)
downloaddotfiles-c67d4836f4d6d5e6c8ef4e2de38bd21ccb6ee1a1.tar.gz
tidy and simplify shell init
Rely on SPWCRONTAB property to set PATH for cronjobs, and otherwise rely on .profile, .xsessionrc etc. to set PATH, once, at login. Just archive scripts I haven't used lately which might otherwise need more significant adjustments, or appear to be broken in other ways.
Diffstat (limited to 'archive/bin/rt')
-rwxr-xr-xarchive/bin/rt25
1 files changed, 25 insertions, 0 deletions
diff --git a/archive/bin/rt b/archive/bin/rt
new file mode 100755
index 00000000..66c8a864
--- /dev/null
+++ b/archive/bin/rt
@@ -0,0 +1,25 @@
+#!/bin/bash
+. $HOME/.shenv
+
+# first check that there exist the dirs we need
+
+if [ ! -e "$HOME/local/rt/watch" -o ! -d "$HOME/local/rt/session" -o ! -d "$HOME/local/rt/incomplete" -o ! -e "$HOME/local/rt/complete" ]; then
+ echo "I was asked to start rtorrent, but one of the dirs in ~/local/rt is missing" >&2
+ echo "(myrepos fixups should do it)" >&2
+ exit 1
+fi
+
+# start rtorrent under dtach if it's not running
+
+if ! pgrep -u $LOGNAME rtorrent >/dev/null; then
+ rm -f $HOME/local/rt/session/dtach.socket
+ TERM=xterm nice -n 19 dtach -n $HOME/local/rt/session/dtach.socket rtorrent
+fi
+
+# if we're not at a dumb terminal (so this script can be shoved in a
+# crontab), try to attach what we (maybe) just made
+
+# this is a bashism
+if [ -t 1 ]; then
+ dtach -a $HOME/local/rt/session/dtach.socket
+fi