[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”.
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.
For ubuntu, install the libnotify-bin package.
sudo aptitude install libnotify-bin
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.
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.
not to be a a macfag, but growl has been around since 2004
macfag, how do you do this in a shell script in OSX? I’m making the switch from Ubuntu to OS X.
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.
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.
terry,
http://www.macosxhints.com/article.php?story=20070602201030683
http://blog.wi.id.au/2008/07/07/os-x-command-line-fun-with-growl/
Good to see that a windows utility I’ve had since 1996 is available on linux and mac (since 2004).
“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.
Hey Mike, what theme are you using :) That taskbar looks mighty smooth.
@fiveseven: I’m using the “New Wave” theme. I believe it comes standard with Ubuntu 9.04
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 “$*”
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.
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..
Hey kids, did you know you can write messages to the system log with the “logger” command?
It’s true!
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.
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.
@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.
@jojo: pwnd! winfaggot
Wow, now with e-dawg gone, this place is turning into /b/ for geeks.
notify-send “hackaday.com publishes excellent posts”
notify-send “hackaday.com publishes excellent posts