Search code examples
linuxshellubuntuzenity

How to use command "at" in shell to call zenity in ubuntu


I am trying to write a shell script to remind an user. I want to show dialog at a specific time.

I use zenity to show the dialog message

Here is my script

#!bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
at now <<EOF
/bin/zenity --info --text="hello word"
EOF

But it doesn't show anything

Please help me.


Solution

  • Since the command executed by at isn't executed in the same shell, and in the same environment (where you already have a graphical display available), you will also need to specify which display to use, e.g. by setting the DISPLAY environment variable when using zenity:

    DISPLAY=:0.0 zenity --info --text="hello world"
    

    Also, if you're running zenity by writing its absolute path, make sure it's really there. For me, on Ubuntu 14.04 zenity is installed under /usr/bin/zenity, so with your example it wouldn't work.