Simple pop-up notifications

simple_linux_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 hackaday.com"

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. Thumbs up from me. 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. I’ll be playing with it alongside pynotify for my next project.

  6. “Good to see that a windows utility I’ve had since 1996 is available on linux and mac (since 2004).”

    …. just because you are seeing someone post about a tip from linuxjournal now, does not mean it is a new utility.

  7. 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
    #!/bin/sh

    #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 )

    DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$UU/environ | sed s/DBUS_SESSION_BUS_ADDRESS=//)

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

  8. 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.

  9. A nice hack would be to write a dbus library for arduino. It is possible to connect dbus via tcp/ip. Authentication is still a task though..

  10. I have to agree that this isn’t a hack, but it really keeps you up to date on things going on with your server. so its more of a production utility than a hack.

  11. 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.

  12. @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.

    http://en.wikipedia.org/wiki/X_Window_System

    “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

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s