Firstly - stop shutting down with root. Use
Next, put something in your script that detects running torrents. Here is a little something that uses
trasmission-remote to count the number of torrents running that aren't "Done":
transmission-remote --list | sed '1d;$d' | grep -v Done | wc -l
To build that into your script:
count=$(transmission-remote --list | sed '1d;$d' | grep -v Done | wc -l)
if [ $count -eq 0 ]; then
dbus-send --system --print-reply --dest=org.freedesktop.Hal \
I'm not a transmission user so my search might be slightly off but this should do the job. You might find that it doesn't shut down all the time if there are some torrents in there that are, for example, paused. If that's the case, play around with the output and a
grep -v clause or two to handle things.
Additionally, you might want a timed shutdown so you're never in a situation where the desktop shuts down while you're on it (so you can abort it). Perhaps just an additional check in there to see what the time is.
transmission-remote requires you turn on web access to transmission from within its options.