Tag Archives: notifycation

How to receive push notifications from your rtorrent client

1. step:

Download pushover to your device, register, and create a new app on their site:
Name it as you like, eg. rtorrent. Pick a nice icon for the app.

You will need 2 keys for the next step:
– your user key
– and your app’s key

2. Set up a script which will handle the rtorrent’s events.

Ruby needs to be installed on your system.
Open your favourite editor and paste the following script:

#!/usr/bin/env ruby
require "net/https" url = URI.parse("https://api.pushover.net/1/messages.json")
req = Net::HTTP::Post.new(url.path) 
req.set_form_data({ :token => "YOUR_APP_KEY", :user => "YOUR_USER_KEY", :message => "start " + ARGV[0], }) 
res = Net::HTTP.new(url.host, url.port) 
res.use_ssl = true res.verify_mode = OpenSSL::SSL::VERIFY_PEER 
res.start {|http| http.request(req) }

Replace the two placeholders with your keys (YOUR_APP_KEY and YOUR_USER_KEY)
You would save it to /usr/local/bin (you need administrator privileges) and then make it executable:

chmod +x /usr/local/bin/rtorrent-pushover.rb

At this point, you can try it working with the following command:

/usr/local/bin/rtorrent-pushover.rb "test message"

3. Change your rtorrent config to call the notification script.

Add the following line to your ~/.rtorrent.rc file:

system.method.set_key = event.download.inserted_new,notify_me,"execute=/usr/local/bin/rtorrent-pushover.rb,$d.get_name="

If you would like, you can set up another notification for the finished torrents.
In this case, the only thing you should change is the “event.download.inserted_new” to “event.download.finished”.

If you’ve set up everything correctly, you should receive notifications about new torrents to your device.