I need help fixing AppleScript for an app called "Transmission"
I am trying to write code to get it to quit once downloads are finished
Is this the proper code:
-- Quit Transmission, if running
tell application "System Events"
if ((count (every process whose name is "Transmission Download")) = 0) then
tell application "Transmission"
-- Quit Transmission
quit
end tell
end if
end tell
Best Answer
Transmission does not support AppleScript specifically, so there is no way to use AppleScript to check if downloads are still active or not.
There's a concurrent discussion of this idea going on at https://forum.keyboardmaestro.com/t/applescript-for-transmission-app/15789 but this is probably a better place for it, so I'll summarize my answer from there.
Install
transmission-cli
usingbrew
:brew info transmission-cli
Enable the "Remote" feature of Transmission app:
You do not have to limit to
127.0.0.1
but unless you need to access from another computer, there's no harm in leaving that on.If Transmission is running, but there are no items in the list, it will be quit.
There may be other ways of doing this, but I cannot think of any myself (other than just using Transmission's preference to run a script when a download is complete, and quitting the app then, but that will fail if there are multiple concurrent downloads active).