Howto auto-shutdown deluge(not pc) when downloads finish.

Suggest, post, or discuss plugins for Deluge
mhertz
Compulsive Poster
Compulsive Poster
Posts: 795
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Howto auto-shutdown deluge(not pc) when downloads finish.

Postby mhertz » Sat Aug 13, 2016 9:19 pm

There are plugins available to shutdown computer after differen't occasions occure e.g. downloads finish, but I cannot find neither plugin nor native function to let deluge shutdown itself(not pc) automatically when all downloads finish. Qbittorrent and utorrent etc has atleast functionality to do that from the main menu, so I find it weird not being a possibility for deluge which is so flexible and support pretty much whatever you could possibly want/need. I'm thinking maybe an execute script set to run after each download finished could do it i.e. query with the console-ui if there's downloads still left and then force close accordingly if not, but not a very elegant solution though.

Thanks in advance.
Last edited by mhertz on Sat Aug 20, 2016 10:08 pm, edited 3 times in total.

Cas
Top Bloke
Top Bloke
Posts: 3642
Joined: Mon Dec 07, 2009 6:04 am
Location: Scotland

Re: Howto auto-shutdown deluge when downloads finish.

Postby Cas » Sun Aug 14, 2016 11:05 am

Autoshutdown plugin only performs the action once all downloads are complete

mhertz
Compulsive Poster
Compulsive Poster
Posts: 795
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Howto auto-shutdown deluge(not pc) when downloads finish.

Postby mhertz » Sun Aug 14, 2016 4:19 pm

OK, you just got me to test with Autoshutdown, which I haden't before due to it's description of functionality, and btw, to get it to even enable, you need to install 'python2-dbus' on Arch linux, and not python-dbus as the long thread mentions which I just perused quickly.

Anyway, the plugin does exactly as described i.e. not fulfilling my requested functionality; Again I wanted auto-shutdown/quiting of deluge, not my entire system, and yes only when all torrents finish downloading. Most other clients have such option, so it puzzled me that I couldn't find it, but I guess i'll have to write an execute bash script to grep some state file or something in the deluge config dir and pkill deluge forcefully when all torrents finished downloading, though not very elegant.

Please anyone update me if you have a suggestion or something i've missed, thanks.

Cas, thank you for reply and your work on deluge, we all very much appreciate your efforts.

Edit: I tried to make this functionality by making a script that is invoked by the execute plugin every time a torrent is removed(as I use seedtime plugin to auto-remove torrent when download finishes) and this script checks if there's any torrents left by checking for torrent files under '~/.config/deluge/state' and if no left pkills deluged and deluge-console, but unfortunetly I cannot get the execute plugin to work as it's never executing my script for some reason. I followed all the instructions and of course used correct full paths and script made executable and having user write access and also tested script fine standalone. When googling it I read another user also not being able to get the execute plugin run propperly and he found out the issue was having auto-login enabled, which I have too on my arch-linux system, so i'm gonna test that out later too by disabling that. Again, any input greatly appreciated.

mhertz
Compulsive Poster
Compulsive Poster
Posts: 795
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: Howto auto-shutdown deluge when downloads finish.

Postby mhertz » Fri Aug 19, 2016 1:50 am

OK, I fixed this issue for myself now. The execute plugin could be used with a script running upon each finished download e.g. 'deluge-console info | grep Downloading || pkill -9 deluged', but instead of adding another plugin to my setup, then I thought I might as well simply add this functionality to my bash-script that is used to open magnets and torrents in firefox through deluged with 'deluge-console add $1':

I have defined the following 'deluge-run' bash-script to be the magnet and torrent handler app in firefox:

deluge-run:

Code: Select all

#!/bin/bash
pgrep deluged || deluged
sleep 2
deluge-console add $1
pgrep deluge-down && exit
echo "#!/bin/bash" > /tmp/deluge-down
echo 'DL=$(deluge-console info | grep Downloading)' >> /tmp/deluge-down
echo 'while [ "$DL" != "" ]; do' >> /tmp/deluge-down
echo 'DL=$(deluge-console info | grep Downloading)' >> /tmp/deluge-down
echo "sleep 30" >> /tmp/deluge-down
echo "done" >> /tmp/deluge-down
echo "pkill -9 deluged" >> /tmp/deluge-down
echo "mpv /usr/share/sounds/speech-dispatcher/test.wav" >> /tmp/deluge-down
echo "rm /tmp/deluge-down" >> /tmp/deluge-down
chmod +x /tmp/deluge-down
/tmp/deluge-down&

Every-time I now click on a magnet or torrent in firefox, then deluged is started in the background(if not already running) and the magnet or torrent is added silently and downloaded in the background, and I can check progress from the terminal with 'deluge-console info', and when all downloads are finished, then deluged is killed and a wav file is played as notification. Note, I use mpv to play the wav and the wav comes from a dependency to chromium; speech-dispatcher, so if not having mpv and speech-dispatcher installed then change that line to whatever you have available on your system instead.

Works for me atleast :)


Return to “Plugins”

Who is online

Users browsing this forum: No registered users and 3 guests