Schedule a zenity message on linux

≯℡__Kan透↙ 提交于 2019-12-08 07:14:33

问题


I want to create a simple reminder on linux at a certain time everyday. I am using crontab to schedule running the reminder script, while in the script I am using zenity to display a simple dialog box with a question.

In more details, I have the following script reminder.sh:

#!/bin/bash
zenity --question --text="question?"

Then, using crontab -e, I add the following task to run every single minute (just for testing):

* * * * * /path/to/reminder.sh

But the dialog box doesn't appear. I added some other commands to the script and I confirmed that the script runs every minute, but the dialog box still doesn't appear!

Any hints?


回答1:


I did find the solution. When I did echo of the $DISPLAY in the same script, it has nothing in it. So, I've set it to my machine display. But this didn't work till I added xhost + to the script.

The final script would look like:

#!/bin/bash
xhost +
/user/bin/zenity --question --text="question?" --display="myMachine:0.0"


来源:https://stackoverflow.com/questions/21414086/schedule-a-zenity-message-on-linux

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!