Simple Pop-up Notifications


[Kristofer] shares a tip on a simple way to add pop-up notifications to Linux scripts. The package libnotify allows you to use the command “notify-send” to pop up a message when you need it. The syntax is simple enough, just place your message in quotes after the command like so:

notify-send "Go read"

There are a lot of other options that go along with this command such as adding an icon and setting how long the message will be displayed. This would be great for projects that interface through scripts, displaying messages as events happen. For Ubuntu, installing this package was as simple as “sudo apt-get install libnotify-bin”.

24 thoughts on “Simple Pop-up Notifications

  1. How is this a hack? This is a simple command line utility that has been around for years doing exactly what it was meant to do.

    This is the GUI version of “print ” for linux.

  2. Yeah agree with darwinsurvivor… this isn’t a hack but, rather, a way to use the libnotify package. There are many ways to do so including pynotify (for use in python) and other tools like zenity and so forth.

    Handy tip though… and if anyone is looking to use this for scripts, I would recommend wrapping everything in some python and just using pynotify for the notification portion.

  3. It is indeed simple and obvious for long time GNU/Linux users but it is still a good tip for new
    users. Also it is hardly a hack.

    Just my 2 cents: If you want to write text on your screen like a OSD, try the osd_cat command provided by the libxosd package.

  4. I have been popping notifications up for a while, with xmessage. Does this package offer any sort of advantage, such as, for example, console notifications? That would be news to me.

  5. What _is_ a hack is this little script that lets root send messages to the current logged in users X session.

    simonvc@katana:~$ cat /usr/local/bin/root-notify-send

    #find out who is running X by looking for the screensaver

    UU=$(ps -ef | grep gnome-screensaver | grep -v grep |awk ‘{print $2}’)
    US=$(ps -ef | grep gnome-screensaver | grep -v grep |awk ‘{print $1}’)
    ESS=$(iwconfig eth1 | grep ESS | awk ‘{print $4}’ | sed s/ESSID:// | sed s/\”//g )


    sudo -u $US DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS /usr/bin/notify-send “$*”

  6. I agree, not a hack. For brevity I have clipped the most relevant definition:

    * Main Entry: hack (2)

    6 : a usually creative solution to a computer hardware or programming problem or limitation

    Now if there is an official definition that applies, by all means let me know.

  7. Thats the thing guys, like D1g1talDragon said,
    “Even if the package has been around a while, it’s always nice to have attention called to something I don’t specifically search for.”
    Who cares if there is something older or newer. Thats not why I visit Hackaday ever day. So I wasn’t thinking about my particular scripts giving feedback with popups, but than I saw this article, and although I had prior knowledge of other ways of creating popups, it was the injection of the idea that helped me out. So stop your flippin whining about this not being up to your standard.
    Hackaday: Keep up the good work.

  8. @jojo
    And which utility is that? You are full of shit.

    Since you first started the “we had it first” flame war, take this dumbass:

    xmessage command which does the same is available since the early beginnings of X11 servers.

    “The current protocol version, X11, appeared in September 1987.”

    Good to see that a UNIX utility I’ve had since 1987 is available on windows (since 1996).

    Suck it, LOL.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.