ambevar-dotfiles/.scripts/trc

33 lines
714 B
Plaintext
Raw Normal View History

#!/bin/sh
2014-01-06 15:17:56 +01:00
if [ "$1" = "-h" ]; then
cat <<EOF>&2
2014-01-06 15:17:56 +01:00
Usage: ${0##*/} [OPTIONS]
With no argument, start transmission-remote-cli. Otherwise, run
transmission-remote with the provided options.
In both cases if transmission-daemon is not running it will be started
beforehand.
EOF
exit
2014-01-06 15:17:56 +01:00
fi
for i in transmission-daemon transmission-remote-cli ; do
if ! command -v $i >/dev/null 2>&1; then
echo >&2 "'$i' not found"
exit 1
fi
done
2014-01-06 15:17:56 +01:00
ps -U "$USER" -o comm= | grep -q transmission-da || transmission-daemon
if [ $# -eq 0 ]; then
exec transmission-remote-cli
else
## The 'sleep' is needed here to give the daemon some time to start. 1 sec
## should be enough on most system.
sleep 1
transmission-remote "$@"
fi