Hai, Recently I changed my broadband plan to unlimited. The new plan is much slower than the old one and I can't browse pages smoothly when my torrents are active. So I have to pause all downloads when I'm using my computer and resume before I go somewhere. The problem is, most of the times I forgot to do this; At last I decided to write a program to automate it :)
You must enable your screensaver before running this program and turn on the web client of transmission torrent
[ edit > preferences > web ]
# This program automatically resumes your transmission torrent downloads
# when your computer is idle and pause when its active.
# ( you must enable your screensaver and turn on webclient of transmission torrent )
# [ Author : Sreekumar ]
#
#
import gobject
import dbus
import os
from dbus.mainloop.glib import DBusGMainLoop
DBusGMainLoop(set_as_default = True)
session_bus = dbus.SessionBus()
def stateChanged(state):
#state : represents wheather the screensaver is avtive or not
if state == 1:
print "Resuming Downloads..."
#resumes all transmissions
os.system("transmission-remote --torrent all --start")
else:
print "Downloads Paused!"
#pause all transmisssions
os.system("transmission-remote --torrent all --stop")
session_bus.add_signal_receiver(stateChanged,"ActiveChanged","org.gnome.ScreenSaver")
#this is to check for new events from each of the event sources and dispatch them
mainloop = gobject.MainLoop()
mainloop.run()
Hope you like it :)