transmission-auto 799 B

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/sh
  2. if [ "$1" = "-h" ]; then
  3. cat <<EOF>&2
  4. Usage: ${0##*/} [OPTIONS]
  5. With no argument, open Transmission's interface. Otherwise, run
  6. transmission-remote with the provided options.
  7. In both cases if transmission-daemon is not running it will be started
  8. beforehand.
  9. EOF
  10. exit
  11. fi
  12. for i in transmission-daemon transmission-remote ; do
  13. if ! command -v $i >/dev/null 2>&1; then
  14. echo >&2 "'$i' not found"
  15. exit 1
  16. fi
  17. done
  18. ## The command is often displayed as transmission-da.
  19. ## The 'sleep' is needed here to give the daemon some time to start. 1 sec
  20. ## should be enough on most system.
  21. ps -U "$USER" -o comm= | grep -q transmission-da || { transmission-daemon && echo "Daemon started" && sleep 1 ; }
  22. if [ $# -eq 0 ]; then
  23. $BROWSER http://localhost:9091/
  24. else
  25. transmission-remote "$@"
  26. fi