Notify-send可以在事件(Event)发生时用于提醒用户,比如“脚本运行完毕”时,就触发了一个典型的事件(Event)。
如果你的系统里没有安装notify-send,从软件仓库里安装"libnotify1"或"linotify”即可。譬如在ArchLinux下:
$ pacman -S libnotify
默认情况下,提示消息将持续限时5秒钟。我们可以用“-t"选项来改变消息现实时长,默认的单位是毫秒。比如下面的命令将持续显示提示信息3秒钟:
$ notify-send "This message will be displayed for 3 seconds" -t 3000
-t 0选项将不会自动关闭提示框,只有用户在点击提示区后,该提示框才会消失:
$ notify-send "This dialog will not vanished, until you click " -t 0
你可以为提示框加上标题和图标,例如:
notify-send "This is the Title" \
"Check out the cool icon" \
-i /usr/share/pixmaps/gnome-terminal.png
下面的脚本用于循环告知用户相应事件的发生:
#!/bin/bash
while [ 1 ]; do
notify-send "Up Time" "`uptime`"
sleep 5m
done
原文来源: http://www.linuxjournal.com/content/tech-tip-get-notifications-your-scripts-notify-send