Native notifications in Gnome

    It will be about notifications that show almost all applications from Rhythmbox to network connections. I wanted to be able to show my own in this form and therefore I took a tambourine and started to drip)



    first I need to install the libnotify-bin package, I launched a command under ubuntu

    sudo apt-get install libnotify-bin

    after that a little test. We check in the console

    notify-send test

    if you have such a window, then you can move on and deal with the settings notify-send [OPTION ...] [BODY] - create a notification -u, --urgency = LEVEL There are not many options here, low, normal , critical. The difference is only in the strip that appears on the left side. -t, --expire-time = TIME Specifies the timeout in milliseconds at which to expire the notification.









    Everything is clear here, we indicate the time in milliseconds that the notification will hang on the screen.

    -i, --icon = ICON [, ICON ...] Specifies an icon filename or stock icon to display.
    With the icon, everything is fine too, Firstly, you can directly specify the path to any image on the disk. Another option is to open / usr / share / icons / hicolor / 48x48 / apps / and select any there and specify its name only without the extension notify-send -i pidgin test

    -c, --category = TYPE [, TYPE ...] Specifies the notification category.
    according to the idea, assigning a category should have yielded results, but I believe it didn’t notice it, so let

    's move on -h, --hint = TYPE: NAME: VALUE Specifies basic extra data to pass. Valid types are int, double, string and byte.
    hints give a great opportunity for customization, for example, the location on the screen where the notification should appear -h int: x: 500 -h int: y: 500

    now in the text, 2 texts are accepted, the first goes to the header, the second is a body with small hypertext capabilities notify-send "Hat" " bold italic link " after you figured out the settings, the thought immediately begins to arise, and where to apply it and the first is its own organizer. All the time they say that you need to break away from the monitor every 45 minutes, which means there is a chance to do it. The first step is to write a small script that is important here, it is DISPLAY, the crown does not see it point-blank and therefore, although the commands will be executed, nothing will appear on the screen.







    #!/bin/sh

    export DISPLAY=:0.0
    PATH=/usr/bin/:/bin/
    notify-send --urgency normal --expire-time=10000 -i typing-monitor -h int:x:500 -h int:y:500 "Пора сделать перерыв" "Глазам нужен отдых"



    keep put on execution and check the result like? then it's up to setting up the crown Well, here for more information, please visit http://www.galago-project.org/specs/notification/0.9/x211.html cross-posting http://mymans.org/2008/12/26/500 Supplement from spiritedflow As for DISPLAY =: 0.0. The hard-hit DISPLAY is not good. It can change from time to time, even if there is only one user at the computer. In addition, if you closed the session and left, the crown will still work and errors will be poured into your mail. It is better to define it automatically, for example, using the following function: # get_display [USER] - Returns $ DISPLAY of USER.

    chmod a+x sh1.sh
    ./sh1.sh





    45 * * * * /home/rus/sh1.sh












    # If first param is omitted, then $ LOGNAME will be used.
    get_display () {
    who \
    | grep $ {1: - $ LOGNAME} \
    | perl -ne 'if (m! \ (\: (\ d +) \) $!) {print ": $ 1.0 \ n"; $ ok = 1; last} END {exit! $ ok} '
    }

    And correct it in the script like this (in one line it is impossible, since export knocks $?):

    DISPLAY = $ (get_display) || exit
    export DISPLAY

    Also popular now: