I am running Xubuntu 15.04, but maybe this question has a general solution for all Ubuntu flavours.
I usually leave long computations running in a terminal window, which may take from a couple of minutes, to hours, or days. It would be nice if I could be alerted somehow when a terminal finishes executing a command. This should only be necessary for terminals which are minimized.
Is there a way to set up something like this? Ideally, the terminal window could flash, or maybe a notification show up.
There's couple of ways, both with
&&
(logical AND) operator (which runs only when last command succeeded). If you want to run notification regardless of whether command succeeded or failed, use semicolon;
instead of&&
.Graphical
Audio:
Note, you can use any audio file instead of the one I used here.
Both:
You can use zenity to display a popup.
After your shell command, append
I suggest using libnotify's
notify-send
for notifications. I've created the following script to do this:If you save above script in a file called e.g.
nexec
and make it executable usingchmod +x nexec
, and move the program to a directory in your shellsPATH
variable, (e.g./usr/local/bin/
), you can run any command withE.g.
libnotify will (at least it does so on my system, I assume this can differ between different desktops) display notifications marked as 'critical' until they are being dismissed manually (e.g. by clicking on them). As you can take from the code, you will receive a different notification if the command returns a non-zero result.
Have you ever heard of undistract-me? It seems it fits your needs and its code it's on github.
I think the package is in the official Ubuntu repos, so should be sufficient
then you have to close and reopen any terminal you have, just to let the changes take effect and you can test it with a simple
Remember to change your active window, otherwise you won't see any notification.