Use dbus. 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":. 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. Note: transmission-remote requires you turn on web access to transmission from within its options.
Transmission offers an RPC interface that let's you communicate with Transmission programmatically. With that, you could write a script that is executed after one any torrent is finished downloading, as you do now.
That scripts checks through the RPC interface if there are any other torrents still downloading. Only if none are found, the system is shut down, else the script exits without doing anything and waits to be called again once the next torrent finishes.
So it shouldn't be to hard to write a script in any of those languages to do the task described above. Like Henning said, make use of the transmissionrpc to get the status of all the torrents. If none of them are still active then you can go ahead and shutdown your computer. I've written a little program in Python to do this.
You can find it here. Ubuntu Community Ask! Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group.
Create a free Team What is Teams? Learn more. Mr Transmission, please turn off the PC after all downloads are completed!
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. Note: transmission-remote requires you turn on web access to transmission from within its options. Skip to content scripts shutdown torrent-client transmission! How can I improve it?
The script runs perfectly on my machine Ubuntu The problem is that when I'm downloading more than one file, when the first one finishes, transmission executes the script. I would like to do that but after all downloads are completed.
I want to put a 2nd check right after monitor check if it is still downloading another torrent. This information isn't passed to the scripts via environment variables, so you'll need to query Transmission's RPC interface. This is sometimes done by client libraries -- for example, a Python script could use python transmissionrpc.
Here's a quick approach that will use transmission-remote to count the number of non-idle downloads:. I created a better script from user advice which takes advantage of transmission's RPC Interface.
0コメント