Blog

Utilising the notification system in KDE or Gnome in bash scripts (ubuntu 9.10 / linux)

So you want to use the nice notification features available in your desktop environment (KDE or Gnome) from a script you wrote? Below explains how to do just that for the two different environments.

KDE

The code below will use kdialog (should be installed along with kde) to create a popup message that displays for 3 seconds before closing:

kdialog --passivepopup 'notification message!' 3

This should look like the image below:

kdialog passive popup notification

kdialog passive popup notification

Source: stackoverflow

Gnome

A similar tool is available for gnome, but to the best of my knowledge (I don’t really use gnome) you need to install a package. The libnotify-

sudo apt-get install libnotify-bin

The command notify-send can then be used to create notifications from your script.

notify-send -t 3000 "notification title" "notification text"

Where 3000 is the timeout in milliseconds (so 3 seconds). notify-send features some nice additional options such as the ability to include images eg:

notify-send -i /home/user/exampleicon.png -t 3000 "notification title" "notification text"

Source: Coder’s Talk

3 Comments

  1. […] just stumbled across this handy little trick over at StealthCopter.com. notify-send -t 5000 "Title" "Hello, […]

  2. thirdy

    Thanks! I just got to make a simple script to notify & then activate the screensaver (for 10s) for every 20m to rest my eyes 🙂
    I’ll be posting this on my blog

  3. Rombus

    This is awesome! Thanks dude.

Leave a Comment

Your email address will not be published. Required fields are marked *