Tech Tip: Get Notifications from Your Scripts with notify-send
Notify-send is a great application for notifying you when an event has occurred. An event such as a script running to completion.
If notify-send is not installed on your machine already, install the package "libnotify1" (or possibly just "libnotify") from your repositories.
Once installed you can simply type the following, at the command line, to display a pop-up message near your system tray:
notify-send "hello"
By default the message will be displayed for 5 seconds. To change how long a message stays displayed use the "-t" switch. This will change, in milliseconds, how long the message is displayed. Enter "-t 0" to leave the message up until the user closes it.
notify-send "This message will be displayed for 3 seconds" -t 3000 notify-send "Click me to close me." -t 0
You can even add a title and an icon to the notification.
notify-send "This is the Title" \
"Check out the cool icon" \
-i /usr/share/pixmaps/gnome-terminal.png
When used in a script you could set it to notify you periodically by placing the command in a loop:
#!/bin/bash
while [ 1 ]; do
notify-send "Up Time" "`uptime`"
sleep 5m
done
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
- Using Salt Stack and Vagrant for Drupal Development
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- New Products
- RSS Feeds
- New Products
- This is the easiest tutorial
6 hours 11 min ago - Ahh, the Koolaid.
11 hours 50 min ago - git-annex assistant
17 hours 49 min ago - direct cable connection
18 hours 12 min ago - Agreed on AirDroid. With my
18 hours 22 min ago - I just learned this
18 hours 26 min ago - enterprise
18 hours 56 min ago - not living upto the mobile revolution
21 hours 47 min ago - Deceptive Advertising and
22 hours 23 min ago - Let\'s declare that you have
22 hours 24 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.



Comments
Messages to a Login Screen?
Can any of the mentioned tools be used to display a message to a computer's login screen if no one is logged in there?
I'm trying to test/verify some special shutdown tasks and I'd like to see the output even if I'm not logged in.
Any help?
BTW, the original post was very helpful. Thanks,
Sam
alarmclock based on notify-send
In file "alarmclock":
How it works:
Pops-up 10 notifications at the desired time as desired. Now if I could just get the window center and larger . . . maybe have to write some C to call X functions, or figure out how to call libnotify with different args? Thanks, Kristofer, for the excellent tip.
excellent information
Really this post is super. The information in the post is very useful. Tech tips are really good idea. We are expecting you to post more tips. Thanks for sharing such a good and useful tips.
Unicode
I was making a weather popup -- I work in a sub-basement and always want to know what things look like when I go up to ground level -- and I wanted to stick the degree symbol (°) with Unicode and got a circumflex capital A (°) first. Any idea. When I print the string to STDOUT, no problem. When it goes to notify, no dice. Perl, btw. Is there a Unicode-safe way of handling this?
Reply To Self
Not a notify-send issue. A Perl issue. See http://ahinea.com/en/tech/perl-unicode-struggle.html . Nevermind....
OSD
I like osd_cat best myself.
Some trick: (sleep 55m;
Some trick:
(sleep 55m; notify-send "Laundry Done!" -t 0) &
And you can use gmessage, zenity, kdialog instead too.
gmessage -center -nofocus -font 'Sans Bold 48' "Laundry Done"
zenity --warning --text="Laundry Done!"
kdialog --passivepopup "Laundry Done!"
from http://kldp.org/node/106625 (Korean)
Debian systems and other tools?
The binary is in package libnotify-bin on Debian systems.
However, it shows me that (IMHO) ugly (maybe GTK?) notification pop-up message in the lower right part of the screen, while my system tray is not there.
Is there any other similar tool? I'm using zenity to accomplish a similar thing. Even thought it's pretty powerful in options, I don't see it being able to show exactly where you want it on the screen, unless you want it in the middle of the screen. ;)
domdelimar.com
Re: other tools?
Oh, I just realized there's kdialog which still shows somewhat ugly (IMHO) notifications on KDE3 but seems to integrate really nicely with KDE4. At least, on KDE3 that I know of, it allows you to position your notification wherever you wish on the screen. Nice.
domdelimar.com
Can send a notification to another Ubuntu ?
Hello,
Can I send a Pop-Up Notification to another PC with UBUNTU system.
Thanks a Lot.
Jonathan.
Twitter: jonathanroco
Re: notification
If you have ssh and X forwarding enabled on the remote system, you can send a notification like this:
ssh -X user@remote.system DISPLAY=:0 notify-send "Hello there"This assumes that user has an X session running on :0, of course.
Re: notification
Note that the "
-X" (X forwarding) is not necessary here. X forwarding is used for executing remote commands that have to display their X contents on the local display, i.e.: "ssh -X user@remote.system xterm" would attempt to execute "xterm" on "remote.system", while displaying on my local display (forwarding the X11 communications over the SSH connection), effectively giving me a shell on "remote.system". What you want is to execute a command (doesn't really matter where), and have it display on the remote system.Given that,
ssh user@remote.system DISPLAY=:0 notify-send 'Hello there'Would presumably work equally well, assuming that
userhas permissions to access the display at:0.Not sure if libnotify/notification-daemon has any provisions for remote connections (if so, you'd expect something like "
DISPLAY=remote.system:0 notify-send 'Hello there'" to work as well; I have little hopes in that regard, though).You forget something with
You forget something with the quotes. That is the real command:
ssh -X user@remote.system DISPLAY=:0.0 'notify-send "Hello World!" '
Only with the notify command between quotes ssh works fine.
Regards,
JR.-