安排在Linux上的zenity消息 [英] Schedule a zenity message on linux

查看:129
本文介绍了安排在Linux上的zenity消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在一定时间每天在创建Linux上的简单的提示。我使用的crontab 调度运行催剧本,而剧本我使用的zenity 来显示一个简单的对话框一个问题框。

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.

在更多的细节,我有以下脚本 reminder.sh

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

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

然后,使用 crontab -e命令,我添加了以下任务运行的每一分钟(只是用于测试):

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!

任何提示?

推荐答案

我没有找到解决方案。当我做回声在同一个脚本中的 $ DISPLAY ,它有什么也没有。所以,我将它设置为我的机器显示。但这并没有工作,直到我加入 xhost的+ 的脚本。

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.

最后的脚本看起来像:

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

这篇关于安排在Linux上的zenity消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆