If you use Transmission this little python script will start all of your downloads when your screensaver kicks on and pause them when it turns off, i.e. you are at your terminal.
#!/usr/bin/env python import dbus, urllib from dbus.mainloop.glib import DBusGMainLoop START_TORRENTS = "http://localhost:9091/transmission/rpc?method=torrent-start" STOP_TORRENTS = "http://localhost:9091/transmission/rpc?method=torrent-stop" DBusGMainLoop(set_as_default=True) sess=dbus.SessionBus() def sig(screensaverActive): if screensaverActive: data = urllib.urlopen(START_TORRENTS).read() else: data = urllib.urlopen(STOP_TORRENTS).read() sess.add_signal_receiver(sig, 'ActiveChanged','org.gnome.ScreenSaver') import gobject loop = gobject.MainLoop() loop.run()via I can’t find it at the moment but I will update once I get the link.
![]()
UPDATE:
I found my source here. The comments also include a patch for throttling the app rather than outright pausing everything.
SECURITY: I should point out, as mentioned in this comment, the RPC for Transmission will allow a nefarious person to control your application with a web page that includes elements like:
<img src="http://localhost:9091/transmission/rpc?method=torrent-stop">It is assumed that most (all?) other RPC calls for the web interface of Transmission could be called the same way. This is a fairly large security hole and I would suggest using a password on the Transmission web interface if you enable it. Though if you do that would render this tip pretty much useless.
Tags: automation, bittorrent, python, rpc, security
Ping a host until it answers and then connect. I actually have this in a script that will use the first argument as the host.
while ! ping -W 1 -c 1 <hostname or IP> 2>&1 >/dev/null; do true; done && sleep 15; ssh <user>@<hostname or IP>via The Linux Blog
This site was inspired by Vinny B A’s Txt site. I liked the idea of a central place to keep all of the gems one comes across in their life as a code/command line jockey. Hopefully you find something helpful here but remember this site is primarily for my benefit and as such I will generally not be enabling comments unless I specifically am asking for feedback.
I have also looked into the problems with displaying code in Wordpress (or any blog for that matter) and I have installed a couple of plugins in hopes of helping out with that.
The first is Visual Code Editor which helps with the problems inherant with trying to display HTML markup in a page without the browser trying to render it and also issues with WP trying to make single and double quotes all cutesey and curly.
The second is, at the suggestion of the author of the previous pugin I have installed SyntaxHighlighter Plus so I can get some nice higlighting.
Feel free to drop me a line at the admin email address if you have any suggestions.
Code on.