4

I'm running Lubuntu 12.04. I have a shell script that tests for a network condition and need some way for it to pop up a notification in the GUI. The network testing part is done, but I need some help with the "pop up a notification in the GUI" part.

2 Answers2

11

You can use the default notification daemon to give notifications with an icon.

Just add this line to the shell script where you want to give notification (with appropriate lines and paths).

notify-send -u critical -i <Icon-path> "<Heading>" "<Rest of the message>"

The package providing this is libnotify-bin.

@ThatJackElliott Did you replace <> with appropriate text? You need to remove "<" ">". Icon path is optional. Try this :

notify-send -u normal "Hello Jack Elliot" "This is a trial notification.\nWelcome to AskUbuntu\!"

-u can be low, normal & critical.

See man notify-send for more info.

In case of any problems, these are the packages in my system. They work excellently :

  • gir1.2-notify-0.7
  • libknotifyconfig4
  • libnotify-bin
  • libnotify-dev
  • libnotify0.4-cil
  • libnotify4
  • notify-osd
  • notify-osd-icons
  • python-notify
  • python-pyinotify
  • xfce4-notifyd
  • xfce4-notifyd
VedVals
  • 3,651
5

yeah you can do that with python. open your terminal and type

sudo apt-get install python-notify

Then write a program like this .

frank@august:~$ cat>not.py
#!/usr/bin/python
import sys
import pynotify

if __name__ == "__main__":
    if not pynotify.init("icon-summary-body"):
        sys.exit(1)

    n = pynotify.Notification(
        "Hi Elliott",
        "welcome to askUbuntu!",
        ##dont remove the below line
    "notification-message-im")
    n.show()
frank@august:~$ 

save it with any name , for example noti.py for our case .

open your terminal and type python not.py

Then you will see

enter image description here

Hope that helps.

Credit goes here : Create custom notification on your Ubuntu desktop using python

VedVals
  • 3,651
Raja G
  • 105,327
  • 107
  • 262
  • 331