Whenever I work on something in the terminal that takes time to complete, it is quite common get distracted in the meantime. This is because there’s no notification reminding you about the command that were working with in the terminal, even if it was just a simple system update.
However, there are two ways with which you can get notified when a command completes in your terminal.
You can utilize Noti or simply libnotify-bin package (from the default repository) to get notified.
While this could be a default feature in elementary OS, you can utilize these both methods in Ubuntu (and any other flavors) or any other Linux distribution.
Get desktop notification for command completion in Ubuntu
In my opinion, using Noti is easier and quicker. The second method also works quite well but may not be user-friendly to type every time you work with commands.
Method 1: Using Noti
To get started, you need to install Noti first.
Unfortunately, there’s no package to install nor an easy way to uninstall, let me show you what you can do to set it up.
You need to first download the archive for Linux from its GitHub releases page. Once done, extract it to your home directory or anywhere you like.
Next, to get it installed, make sure you’re in the directory where you have it extracted and then type in:
sudo install noti*linux-amd64/noti /usr/local/bin
Now, all you need to do is type “noti” before any command that you want to be notified about. For instance:
noti sudo apt update
And, you will see something like this:
To remove Noti, you need to navigate to the usr/local/bin directory and remove it manually using commands or the GUI as root.
The commands to do that are:
cd /usr/local/bin
sudo rm Noti
Method 2: Using libnotify-bin package
You should be able to find this package in your default repositories. So, you can easily install it by typing:
sudo apt install libnotify-bin
If you’ve already have it installed, you’re in luck. Now, all you have to do is type “notify-send MESSAGE” after any command you type.
But, make sure to separate it after the command using a semicolon (;)
Here’s how it looks like:
sudo apt update; notify-send Done
You can easily replace “Done” with any text you like and even with a special character like an exclamation mark !
Get desktop notification using Undistract-me (No longer works)
This is no longer developed
undistract-me has been discontinued. Even though you can find it on Ubuntu’s repositories and install it, it no longer works and hasn’t seen a new release for the last 2 years.
undistract-me is a utility that uses notify-usd to notify you of a console command completion. It works only with Bash. To install undistract-me, use the following command in a terminal:
sudo apt install undistract-me
How to use it
To make undistract-me work, you’ll need to do some modification in the ~/.bashrc file. Open it with your favorite text editor and add the following line to it:
. /usr/share/undistract-me/long-running.bash
notify_when_long_running_commands_finish_install
Source the bashrc file like this:
source ~/.bashrc
By default it notifies on the completion, if a command runs for more than 10 second. You can change this default behavior by changing the value of LONG_RUNNING_COMMAND_TIMEOUT in file /usr/share/undistract-me/long-running.bash
If you want to test whether or not undistract-me works properly, just run sleep 11 in the terminal. This will just wait for 11 second and at the end of it, you should see a notification like this:
Wrapping Up
Even if you are not a programmer, you might find it handy while installing an application via PPA or just updating or upgrading the system. The apt update command might take some time to run, depending upon available updates and your network speed, so that could use a reminder.
I hope you find this little tool useful in your desktop Linux experience with terminal notification. In other terminal trick, you can change sudo password time period. If you have questions or suggestion, feel free to drop a comment.