Page 1 of 2 12 LastLast
Results 1 to 10 of 29

Thread: Notify-send HOWTO

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    Netherlands
    Beans
    73
    Distro
    Lubuntu 13.04 Raring Ringtail

    Notify-send HOWTO

    Notify-send is a little, simple On-Screen Display application. It uses the notify bubble (or balloon?) pop-up system as seen in 9.10 Karmic.

    Despite its usage is very simple you can have a lot of fun with it. Let's install it first:

    Code:
    sudo apt-get install notify-osd
    Now this command should pop up a 'bubble':
    Code:
    notify-send Test "Hello World"
    The --help option shows basic usage:

    Code:
    $notify-send --help
    Usage:                             
      notify-send [OPTION...] <SUMMARY> [BODY] - create a notification                                                    
    
    Help Options:
      -?, --help                        Show help options
    
    Application Options:
      -u, --urgency=LEVEL               Specifies the urgency level (low, normal, critical).                              
      -t, --expire-time=TIME            Specifies the timeout in milliseconds at which to expire the notification.
      -i, --icon=ICON[,ICON...]         Specifies an icon filename or stock icon to display.
      -c, --category=TYPE[,TYPE...]     Specifies the notification category.
      -h, --hint=TYPE:NAME:VALUE        Specifies basic extra data to pass. Valid types are int, double, string and byte.
      -v, --version                     Version of the package.
    Some examples:

    1. Basic message with an icon in front of the Title showing 5000 milliseconds
    Code:
    notify-send "Message Title" "The message body is shown here" -i /usr/share/pixmaps/idle.xpm -t 5000
    2. Show contents of a file:
    Code:
    notify-send test "`tail /var/log/syslog`"
    3. Follow log file:
    Code:
    tail -n0 -f /var/log/messages | while read line; do notify-send "System Message" "$line"; done
    4. Format message with HTML:
    Code:
    notify-send Test "<font size=16 color=blue><b><i>Hello World</b></i></font>"
    Last edited by DeusEx; February 22nd, 2010 at 09:21 PM.
    Happy user of Lubuntu, Arch and XBMC

  2. #2
    Join Date
    Oct 2009
    Beans
    10

    Re: Notify-send HOWTO

    To help anyone in my case: if notify-send can't be found to be installed in your system install first libnotify-bin.

    And just a comment: the HTML sample is not working in my system...maybe anyother library is required ¿?

    Thank you DeusEx !

  3. #3
    Join Date
    Mar 2006
    Location
    Netherlands
    Beans
    73
    Distro
    Lubuntu 13.04 Raring Ringtail

    Re: Notify-send HOWTO

    Odd, I don't have a notify-bin package in my repositories. My version of notify-osd is 0.9.24, and for notify-send it's 0.4.5. Perhaps your DBUS version doesn't like the HTML?

    BTW I made a typo, the package to install should be notify-osd (updated first post). the command to send messages is notify-send...
    Happy user of Lubuntu, Arch and XBMC

  4. #4
    Join Date
    Jul 2007
    Beans
    1

    Re: Notify-send HOWTO

    Alguien sabe si el icono tiene que tener caracteristicas específicas para ser mostrado?. No logro que me aparezcan

  5. #5
    Join Date
    Nov 2009
    Beans
    4

    Re: Notify-send HOWTO

    Does anyone know the code if i want it to notify me if someone logs in like via ssh?

  6. #6
    Join Date
    Jan 2008
    Beans
    307
    Distro
    Ubuntu

    Re: Notify-send HOWTO

    Quote Originally Posted by sossanator View Post
    Does anyone know the code if i want it to notify me if someone logs in like via ssh?
    I'm going to bump this, great idea

  7. #7
    Join Date
    Oct 2006
    Location
    United States
    Beans
    625
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Notify-send HOWTO

    Quote Originally Posted by sossanator View Post
    Does anyone know the code if i want it to notify me if someone logs in like via ssh?
    you can try with notifyme and notify-send

    notifyme -C `cat /etc/passwd | cut -d: -f1`
    ^MEDUZA^

  8. #8
    Join Date
    Dec 2011
    Beans
    3

    Lightbulb Re: Notify-send HOWTO

    Quote Originally Posted by sossanator View Post
    Does anyone know the code if i want it to notify me if someone logs in like via ssh?
    I'm a little late, but... The question inspired me to write a bash script to do just that. You can get it here, at my github. (Or here, for direct-download.)

    But here's the simple answer: What you need is something like this.
    Code:
    sudo tail -fn0 /var/log/secure  |
      grep --line-buffered "sshd.*Accepted" |
        while read line; do
          notify-send -u critical "SSH LOGIN" "$line"
        done
    Or, more spiffy-like:
    Code:
    #WARNING: The following uses some special BASH features, meaning, it won't work in dash.
    
    sudo tail -fn0 /var/log/secure |
      grep --line-buffered 'sshd.*Accepted' |
        while read line; do
          timestamp=${line/ $(hostname)*/}
          ip=${line#*from }; ip=${ip% port*}
          msg=${line#*]: }
          notify-send -u critical "sshd: Session initiated by $ip" "[$timestamp]\n$msg"
        done
    The script I linked above also prints notifications for failed login attempts. Hope someone finds it useful!

    Edit: In my sleep-deprived stupor I forgot to link the screenshots I took. Here's two. The rest are at http://b19.org/linux/notify_sshd/.



    Last edited by ryran; December 19th, 2011 at 03:19 AM. Reason: screenshots

  9. #9
    Join Date
    Nov 2009
    Location
    Tijuana, México
    Beans
    3
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Notify-send HOWTO

    Quote Originally Posted by Icegirl View Post
    Alguien sabe si el icono tiene que tener caracteristicas específicas para ser mostrado?. No logro que me aparezcan
    Las reglas de ubuntuforums especifican que debes comunicarte en inglés.
    Ubuntuforums rules specify that you must communicate in English.


    Not all GNU/Linux distros have the same icons, so before you use them, you should check that they exist:

    Code:
    file /path/to/file
    If they do exist, then you can use them with notify-send as specified above.
    Last edited by dualbus; September 15th, 2010 at 03:41 AM.

  10. #10
    Join Date
    Aug 2009
    Beans
    9
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: Notify-send HOWTO

    Quote Originally Posted by dualbus View Post
    Las reglas de ubuntuforums especifican que debes comunicarte en inglés.
    Ubuntuforums rules specify that you must communicate in English.


    Not all GNU/Linux distros have the same icons, so before you use them, you should check that they exist:

    Code:
    file /path/to/file
    If they do exist, then you can use them with notify-send as specified above.
    Tampoco hace falta ser desagradable.
    To be unpleasant is not necessary either.



    Lucid, notify-send 0.4.5 (libnotify-bin 0.4.5-1ubuntu4): html format doesn't work :S
    Last edited by Covi; October 11th, 2010 at 09:15 PM.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •