I do sudo apt-get update
from time to time, and find it frustrating to have to check when it is done doing its thing. Is there anyway I can get it to offer a notification popup or play a sound when it has finished executing, so I can get on with my work?
Sound I can't help you with. However, if you append something like
after your command, you should see a notification pop up in the upper right corner. If the required package is not installed by default,
sudo apt-get install libnotify-bin
should get it for you. The&&
will execute a second command if the first completes successfully.What you want is
sudo apt-get update; alert
. What follows is explanation and rationale.&&
or;
. These have two distinct meanings:command-a && command-b
means that command-a will run first, and then, if it was successful, command-b will run;command-a; command-b
means that command-a will run first and then command-b will run, whether or not command-a was successful. You probably want the semi-colon: you want to be notified when the update or upgrade has stopped running, whether or not it has exited successfully.notify-send
, which takes two parameters: a title and content:sudo apt-get update; notify-send update finished
(if either parameter contains spaces, enclose them in quotation marks).Much quicker and easier to type than
notify-send title content
isalert
. This alias is built into bash by default in at least some versions of Ubuntu, and is easy enough to add if it’s missing from yours (usetype alert
to check whether it’s present). You should get the response,This means that it will simply pull out the last command and send it to
notify-send
, and that the accompanying icon will be an image of a terminal (for a successful command) or an error image (for a failed command).Life has now become even simpler:
command; alert
is very quick and easy to type. It will alert whether or not the command was successful, and the alert will contain an indication of whether or not the command was successful.Incidentally, it has occasionally annoyed me that I am unable to pipe output to
notify-send
, so I wrote a little function to do it for me:This allows me to type
command | notify
. The icon in this case is random, however. Also, you get a notification for each line of output, which is probably not a good choice forapt-get update
.For aplay compatible files
To play a custom sound through the speakers, you can run
*<path_to_sound_file> = path to the sound file
to play the chosen sound file; then you can add a
playsound
alias to~/.bashrc
:*<path_to_sound_file> = path to the sound file
This way you can run
sudo apt-get update && playsound
to play the chosen sound whensudo apt-get update
has finished running.For non aplay compatible files (e.g. .ogg files) (system sounds)
To play a custom sound through the speakers, you can run
to list all
pulseaudio
's available sinks' indexes along with their corresponding device; then you can run*<sink_index> =
pulseaudio
's sink's indexto play
/usr/share/sounds/ubuntu/stereo/bell.ogg
through the chosen sink. (Of course you can play any sound you want); then you can add aplaysound
alias to~/.bashrc
:*<sink_index> =
pulseaudio
's sink's indexThis way you can run
sudo apt-get update && playsound
to play the chosen sound whensudo apt-get update
has finished running.I wrote a little scripts to make it. Script is located in github.
Here is installation guide:
Installation
Download or just clone repo
Then add sourcing of script
postexec_notify
to your.bashrc
.Here is
git clone
example of installation:Now restart your terminal. After restart you should see this messages:
Now try to test if notification appear:
Please let me know if something is unclear or you have any issues.