Download events in aria2
In my previous post, I have demonstrated how to use
aria2 as the default download manager
on Unix/Linux and how to
integrate aria2 into Conkeror.
In this post, I’m going to show a simple tip that can cause aria2 to display
notification when it finishes downloading. By default, aria2 provides some input
arguments which are the event handlers for download hooks. Those events include
--on-bt-download-complete
, --on-download-complete
, --on-download-error
,
--on-download-pause
, --on-download-start
, --on-download-stop
. The solution
is to pass a shell script to the event and use that bash script to activate
notification program. For example
You can also pass the event handler command to the aria2 command for starting it as daemon or on RPC protocol. If you are using the command from my previous post, the command will look like this
When aria2 finishes downloading, it will run the –on-download-complete script and pass 3 arguments, the third one is the path to the downloaded file. The content of the notification script.sh file should look similar to this
Notification on Linux
Most Linux distros come with the standard APIs for displaying notification. To
activate it, simply execute the command notify-send "message"
in terminal. The
content of the notification script.sh file is similar to this
You can pass extra arguments to notify-send
for specifying expiry time or
notification icon.
Notification on Mac
Mac OS does not come with a shell application for activating notification. However, you can use Growl or terminal-notifier for displaying notification using Mac’s default Notification Center. terminal-notifier can be installed using Macports, ruby or homebrew
Next, edit the notification script.sh file like this
To set the icon for the notification, you need to create an empty aria2 .app wrapper.
Edit the content Info.plist
file
Open Applications folder in Finder, view info of aria2.app, drag and drop the image you want to the application icon
Now, back to the notification script.sh file and change it to