La maggior parte delle applicazioni può mostrare notifiche ben formattate su eventi che appaiono nell'angolo in alto a destra dello schermo. Sto per scrivere uno script bash che eseguirà un'elaborazione fata e lunga in background e voglio davvero sapere quando sarà finito. Come posso mostrare la notifica Nice da uno script bash?
Se stai usando il nuovo sistema di notifica in Jaunty, vuoi il comando notify-send
notify-send - a program to send desktop notifications
SYNOPSIS
With notify-send you can sends desktop notifications to the user via
a notification daemon from the command line. These notifications can be
used to inform the user about an event or display some form of information
without getting in the user's way.
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.
Trovato in un altro modo, attraverso Zenity
echo 'message:hi' | zenity --notification --listen
(Questo ha anche il vantaggio di essere già installato su Ubuntu.)
C'è anche xmessage che pop-up una finestra, quindi dovrebbe funzionare su qualsiasi sistema X11.
Pro: Consente inoltre di richiedere in modo interattivo all'utente pulsanti.
Con: Come qualsiasi avviso popup, in genere riceve lo stato attivo, quindi se sei nel mezzo della digitazione può scomparire prima di leggere il messaggio.
Per gli utenti di KDE:
$ kdialog --title "Long process completed!" --passivepopup "This popup will disappear in 5 seconds" 5 &
Esiste una soluzione multipiattaforma chiamata Yfiton :
$ yfiton -n desktop -Pmessage="Lunch time!" -Pposition=TOP_RIGHT
notify-send "Hello world"
Fonte: https://superuser.com/a/31919/425838
[la finestra non ottiene l'autofocus]
notify-send -t 0 "Hello world"
Fonte: me stesso; nota: -t
viene ignorato per tutti i valori tranne 0 - come stupido . :(
OR
[la finestra ottiene l'autofocus]
zenity --info --title "Hello" --text "World"
Fonte: https://askubuntu.com/a/804475/327339
OR
--timeout
specificato in secondi] zenity --info --title "Hello" --text "World" --timeout=2
Fonte: io stesso leggendo le pagine man: man zenity
OR
[super-brutto aspetto]
xmessage 'hello world'
In uno script Shell, è anche possibile chiamare l'utilità osd_cat da libxosd.