libnotify - einfach und praktisch

Durch Hack A Day bin ich heute auf das kleine Programm libnotify gestoßen. Dieses erlaubt sehr einfach Benachrichtigungen auf dem Desktop auszugeben. Schnell ergeben sich einige Einsatzszenarien:
  1. Systemüberwachung:
    Sehr einfach ist die Ausgabe des syslogs oder von anderen Logdateien. Das geht sicher auch eleganter, aber diese wenigen Zeilen zeigen wie einfach libnotify funktioniert:
    #!/bin/bash
    
    X="EIN"
    syslog="leer"
    syslogalt="leer"
    dmsg="leer"
    dmsgalt="leer"
    publicip="leer"
    publicipalt="leer"
    
    while [ "$X" == "EIN" ] ; do
    
            syslog=$(tail -n 1 /var/log/syslog)
            if [ ! "$syslog" = "$syslogalt" ]; then
                    notify-send -i $HOME/skripte/syslog.png "syslog:" "$syslog"
            fi
            syslogalt="$syslog"
            sleep 5
            dmsg=$(tail -n 1 /var/log/dmesg)
            if [ ! "$dmsg" = "$dmsgalt" ]; then
                    notify-send -i $HOME/skripte/dmesg.png "dmesg:" "$dmsg"
            fi
            dmsgalt="$dmsg"
            sleep 5
            publicip=$(lynx -dump http://checkip.dyndns.org)
            if [ ! "$publicip" = "$publicipalt" ]; then
                    notify-send -i $HOME/skripte/ip.png "Neue IP-Adresse:" "$publicip"
            fi
            publicipalt="$publicip"
            sleep 5
    done
    
    Sehr primitiv und nichts für den Dauereinsatz, aber es funktioniert. Übrigens, unter skripte/ liegen bei mir auch die Icons für die Notifications.
  2. Irssi-Highlights remote:
    Was mich viel mehr begeistert, ist eine andere Möglichkeit. Wie viele, lasse ich Irssi remote in Screen laufen um es nicht immer neu starten zu müssen. Das macht leider die Ausgabe von Highlights als Notification schwieriger und beeinträchtigt so den Nutzen. Durch ein einfaches Skript lässt sich dies aber auch hier lösen:
    #!/bin/bash
    
    ssh server "tail -n 10 $HOME/.irssi/fnotify; > $HOME/.irssi/fnotify; tail -f $HOME/.irssi/fnotify" |
            sed -ru "
                    s/&/\&/g;
                    s//\>/g;
                    s%(#[a-zA-Z]+ )<([^>]{0,10})>%\1\2 %g;" |
            while read heading message
            do
                    notify-send -i "$HOME/skripte/irssi.png" -- "${heading}" "${message}"
            done
    
    Vorlage für dieses Skript war dieses hier. Damit es funktioniert, wird das Irssi-Skript fnotify benötigt, welches in .irssi/scripts/ liegen muss und in Irssi mittels /run fnotify.pl gestartet wird.

Name

Url

Meine Eingaben merken?

Titel:

Text:


JCaptcha - du musst dieses Bild lesen können, um das Formular abschicken zu können
Neues Bild

 

User Status

Du bist nicht angemeldet.

Suche

 

Aktuelle Beiträge

Sorry, dass ich schon...
Sorry, dass ich schon wieder nerve, aber dann sitzt...
Maxe (Gast) - 23. Nov, 22:37
Das erste "tail" ist...
Das erste "tail" ist remote, das zweite lokal. Die...
Barahir - 23. Nov, 20:15
Super
Danke. Kannst du mir jetzt noch verraten, wozu das...
Maxe (Gast) - 23. Nov, 18:23

Charts Lieblingskünstler - Diese Woche

RSS Box

Using an iPhone as a Newton keyboard
[Jesus Alvarez] sent us this funny little project....
Caleb Kraft - 28. Nov, 22:07
GSM enabled security door
The security door at the front of [Oliver's] building...
Mike Szczys - 28. Nov, 20:31
How to use Wiimotes w/ Linux
[Sprite_tm] has whipped up yet another interesting tutorial...
Jacob Woj - 28. Nov, 16:55
Barahir: Hab auch #wave-invites. Wer mag?
Barahir: Hab auch #wave-invites. Wer mag?
28. Nov, 15:08
13th century navigation system
[Tom Wujec] explains how an astrolabe works and its...
Mike Szczys - 28. Nov, 14:52
Four tear-downs for your Friday afternoon
We know that feeling, you’ve been up all morning...
Jakob Griffith - 28. Nov, 02:32
Door opening help
For those who are seeking prosthetic limbs,. ..
Caleb Kraft - 27. Nov, 17:23
Autonomous Turret wielding biped bot
Pay close attention. At roughly 36 seconds we see...
Caleb Kraft - 27. Nov, 15:14
DS goes full size – pockets everywhere rally in protest
It’s hard to believe we missed this one from...
Mike Szczys - 26. Nov, 20:48
Tiny keyboard/touchpad has “hack” written all over...
Yes, we know, this is not a hack, yet it just has...
Phil Burgess - 26. Nov, 16:52
Make any gloves work with a touch screen
The chill of autumn is upon us, and with it comes...
Phil Burgess - 25. Nov, 23:06
Recover borked HDD after Xbox 360 ban
[Incudie] tipped us off about a method to fix a borked...
Mike Szczys - 25. Nov, 21:20
Turkey fryer; awful, bad, and worse
Tomorrow’s turkey day here in the United States....
Mike Szczys - 25. Nov, 20:30
Voice controlled lock? Almost…
If you watched the video before reading...
Jakob Griffith - 25. Nov, 19:13
TI sports watch for hacking
How would you like to have a 3-axis accelerometer,...
Mike Szczys - 25. Nov, 17:55

Status

Online seit 1123 Tagen
Zuletzt aktualisiert: 23. Nov, 22:37