Tha*_*ott 4 notification command-line lubuntu
我正在运行 Lubuntu 12.04。我有一个测试网络状况的 shell 脚本,需要某种方式让它在 GUI 中弹出通知。网络测试部分已完成,但我需要“在 GUI 中弹出通知”部分的帮助。
Ved*_*als 11
您可以使用默认通知守护程序来提供带有图标的通知。
只需将此行添加到要发出通知的 shell 脚本中(使用适当的行和路径)。
notify-send -u critical -i <Icon-path> "<Heading>" "<Rest of the message>"
提供这个的包是libnotify-bin.
@ThatJackElliott 您是否用适当的文本替换了 <>?您需要删除“<”“>”。图标路径是可选的。尝试这个 :
notify-send -u normal "Hello Jack Elliot" "这是一个试用通知。\n欢迎来到 AskUbuntu\!"
-u 可以是低、正常和关键。
查看man notify-send更多信息。
如果有任何问题,这些是我系统中的软件包。他们工作得很好:
是的,你可以用python做到这一点。打开你的终端并输入
sudo apt-get install python-notify
Run Code Online (Sandbox Code Playgroud)
然后写一个这样的程序。
frank@august:~$ cat>not.py
#!/usr/bin/python
import sys
import pynotify
if __name__ == "__main__":
if not pynotify.init("icon-summary-body"):
sys.exit(1)
n = pynotify.Notification(
"Hi Elliott",
"welcome to askUbuntu!",
##dont remove the below line
"notification-message-im")
n.show()
frank@august:~$
Run Code Online (Sandbox Code Playgroud)
用任何名称保存它,例如我们的案例中的 noti.py 。
打开你的终端并输入 python not.py
然后你会看到

希望有帮助。
功劳在这里:使用 python 在您的 Ubuntu 桌面上创建自定义通知