In normal daily usage, Ubuntu has pretty reached the point where the graphical user interface (GUI) could accomplish almost everything. Yet, the underlying Linux command line interface (CLI) is still very much alive. Sometimes, it is simply more efficient to use CLI when you want to accomplish something. You could learn and use this powerful tool to great effect.
A while back, I wanted to improve my crude self-written bash scripts with actual GUI elements, so the final program could be launched interactively (by GUI), and the prompts / messages would also be GUI. Rather than launching a command line terminal, execute the command, and see the prompts / messages in the terminal, you get actual clickable dialogboxes. A great tool for that is Zenity. Later, I discovered another great tool called libnotify-bin.
Popup balloon
Libnotify-bin enabled you to create popup balloon using CLI. This is handy when you wanted your script to show a message on the desktop, but you wanted to do so with something less obtrusive than a messagebox (which the user have to specifically dismiss).
Here is the screenshot of a popup balloon created using libnotify-bin.

Installation
Install the package libnotify-bin via Synaptic Package Manager, or run the following terminal command:
sudo apt-get install libnotify-bin
Usage
To make a popup balloon, you run “notify-send” command. E.g. the popup balloon above was created with this command:
notify-send 'Greetings' 'Hello world!'
As you can see, the command is arranged like this:
notify-send title message
To dismiss the popup balloon, click the [x] icon in the top right corner of the balloon.
Time out option
Of course, a popup balloon that stayed forever is almost as annoying as a in-your-face messagebox. To improve this, you could set a time out option to the command. E.g. this command will display the popup balloon for five seconds.
notify-send -t 5000 'Greetings' 'Hello world!'
The “-t 5000″ is the option that specify a time out of 5000 milliseconds.
Icon option
To make the popup balloon more interesting, you could specify an icon to appear within the balloon.
notify-send -i /usr/share/icons/cab_view.png \ 'Greetings' 'Hello world!'
The “-i icon file” is the option that specify the icon to add. This is the screenshot of the popup balloon from the command above.

Popup balloon location
By default, the popup balloon appeared in the lower right corner of the desktop. You could specify the x and y coordinates in the command to move the popup balloon to another location. The command below will put the popup balloon in the upper left corner of the desktop.
notify-send -h int:x:50 -h int:y:20 'Greetings' 'Hello world!'
Note the options “-h int:x:50″ and “-h int:y:20″ specified the upper left corner of the desktop.

Post a Comment