Ubuntu Linux 桌面送通知訊息

Ubuntu Linux 桌面環境(使用 Unity、Gnome3), 程式要送通知訊息, 可以用下述方式傳送: (apt-get install notify-osd)

  • $ notify-send "hello world"
  • $ notify-send Title "hello world"
  • $ notify-send Date "`date`"
  • $ notify-send "Message Title" "The message body is shown here" -i /usr/share/pixmaps/sm.xpm -t 5000
  • $ notify-send Title "`tail /var/log/syslog`"
  • $ tail -n0 -f /var/log/syslog | while read line; do notify-send "System Message" "$line"; done
  • $ notify-send -i face-wink "Hello! January" # notify-send -i <icon> <Message>
  • $ notify-send  -t 0 "Bringing down the system" # 會彈出需要確認、取消的視窗
  • $ DISPLAY=:0.0 /usr/bin/notify-send "TITLE" "MESSAGE" # 加入 crontab 需要另外顯示
  • $ notify-send -u critical -i "notification-message-IM" 'Boss !!' 'Am done with the execution' # 緊急
  • $ command && notify-send # 程式完成時,呼叫 notify-send 傳送
  • $ notify-send --help # 可以查看更多參數

註: 通知訊息於 Unity 會從上角出現, Gnome3 會從正下方出現 通知訊息.

除了提醒外,想要有出現視窗確認的,可以使用 zenity,如下述:

  • $ zenity --info --text "STRING"
  • 可於 .bashrc 加入此 function,就可以 ls | notify "done" 完成通知
    function notify() {
        zenity --info --text "$1"
    }

作者: Tsung

對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.

發表迴響

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料