如何使用 cron 通过通知发送在屏幕上显示消息

Yot*_*tam 7 cron notifications

我正在玩notify-sendcron(在 Arch 机器上),但我想不出将它们结合起来的方法:

我尝试了herehere给出的解决方案,但都没有奏效。我该如何使用它们?

编辑: 我已经在 crontab 中设置了 DISPLAY,但它仍然没有工作。我在 Ubuntu 中尝试了同样的方法,并且一切正常。这是我的 cron 线:

*/1 * * * * DISPLAY=:0.0 /usr/bin/notify-send "hellp" || echo "er" > .er
Run Code Online (Sandbox Code Playgroud)

Arc*_*ege 4

我唯一可以建议的是创建一个命名管道并让 cron 写入该管道,并由会话管理器启动一个小脚本,该脚本从管道读取并调用通知发送:

while read line < /tmp/.cron2notify.s  # pipe name in /tmp
do notify-send "Cron message" "$line"
done
Run Code Online (Sandbox Code Playgroud)

然后在 crontab 中,让程序写入/tmp/.cron2notify.s.

尚未对此进行测试,但应该为您提供一个工作起点。