notify-send(alert)不弹出GUI bubble消息

当我昨晚发现alias遇到一个名为alert调用notify-send ,它会在桌面上弹出一个GUI bubble消息。 在我的情况下,它是mulit-monitor,在虚拟屏幕上通过内置笔记本电脑定义了电视。 因此,通知气泡(例如音量控制)出现在电视上。

昨晚我测试时:

 alert "Weather Update: It's raining Red States" 

没有出现。 起初,另一位非盟用户和我自己认为这是因为Youtube全屏运行,谷歌Chrome窗口被定义为“永远在线”。 事实certificate,这不是真正的问题,而且这是一次又一次的问题。

如何获得始终有效的alert别名?

PS:我搜索了类似的问题,但是他们要么没有回答和/或没有引用我想要使用的alert别名,因为本机命令很难记住,特别是有必要的控制参数。

别名在〜/ .bashrc中自动创建

当您查看〜/ .bashrc时,您会看到以下行:

 # Add an "alert" alias for long running commands. Use like so: # sleep 10; alert alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' 

代码的问题是--urgency=low flag。 有时会弹出消息,有时则不然。 毕竟它是低优先级对吗?

为了使消息始终显示,设置紧急的紧迫critical 。 我没有更改系统默认值,而是为自己的目的创建了一个新行:

 # Add a "redalert" alias to pop-up on GUI desktop screens. Use like so: # redalert "Weather update: It's raining Red States" alias redalert='notify-send --urgency=critical -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' 

现在你可以使用:

 redalert "Weather Update: It's raining Red States" 

它完美无缺!

alert使用方式与notify-send 。 如果你想为notify-send一个更有吸引力的名字,那就创建一个函数,因为不推荐使用别名。 例如:

 popup(){ notify-send "$@" }