Wouldn’t it be great if you could get pop-up notifications when those long running tasks from the command line finish? Well, you can. Actually, creating desktop notifications from the command line is very simple with the
You can use
notify-send in your scripts or set it to run following a long command that you just typed into the command line. The messages that you create are entirely customizable, and they automatically integrate into whichever desktop environment you’re running, so they don’t look out of place or ugly.
Open up a terminal on your Linux system and create your first notification. Use the one below and see how it works.
Did you see it pop up? Excellent. Try another one.
Now there’s more that you can do to customize your notifications!
Some notifications are more important than others. There are three levels of notifications: low, normal, and critical. Your desktop environment might visually distinguish them, or it might impact how long they appear on screen. You can specify the urgency of your notifications with the
See how that differs from a low urgency one:
Your desktop environment will determine how they behave.
It’d be even better if you could add a graphical component to these messages, wouldn’t it? Well, you can.
notify-send lets you specify an icon. It already “knows” all of your system icons, so if you look under “/usr/share/icons” you can see what’s available there. Use the name of the icon file without the extension along with the
-i flag to add it to your message.
If you don’t like the system icons, you can always point your notifications at custom icons. Just use the path to your icon file.
There are some other flags you can explore. To see them all, run
notify-send --help. A couple of useful ones let you specify the application sending the notification and the time that it stays up. So, if you want your notification to stay up for a specific duration, add the
-a flag lets you specify the app sending the notification. Not every desktop environment includes this information, but it can help you distinguish when ones can.
Scripting is one of the main things that you’d use this whole thing with. It doesn’t have to be a massive complex Bash script either. Say you want a notification when your system is done updating. It can do that pretty easily.
You can get as complex as you want with it, and even create your own wrapper scripts with notifications.
That example is still simple, but you can get an idea of what’s possible.
If you’re computer has SSH configured for X server sessions, you can actually send notifications over SSH, too.
Trolling the people on your network is obviously not the only application for this. You do need the login information just like if you were to add SSH in regularly. It won’t maintain the session, though. It’ll just display the message and exit.
Between SSH and scripting, you can do wide array of things with
notify-send. Experiment and see how you can tailor it to your needs.