On Tue, Jan 28, 2020 at 9:21 AM John Jason Jordan <joh...@gmx.com> wrote:

> On Tue, 28 Jan 2020 06:57:08 -0800
> Ben Koenig <techkoe...@gmail.com> dijo:
>
> >>>Use the $DISPLAY variable to launch on a target X server. Since you
> >>>on a desktop system you probably only have X running once, so try
> >>>something like this
> >>>DISPLAY=:0 gxmessage <args go here>
>
> >> >you can echo $DISPLAY to find out what display is currently running.
> >> >Setting the env variable before any graphical command can be used to
> >> >specify which x server/screen you want it to be displayed on. cron
> >> >jobs run outside of X, so $DISPLAY is usually unset.
> >>
> >> Thanks, but it still isn't working. I started by setting DISPLAY=:0
> >> as in your example, but when it didn't work I did:
> >>
> >> echo $DISPLAY
> >> :0.0
>
> >If the $DISPLAY variable doesn't work, then you can probably use the
> >-display option. I just tried this on my system, and as it turns out
> >you also need to set your Xauthority as well
> >
> >$ XAUTHORITY=/home/<username>/.Xauthority gxmessage -display :0 "Hello,
> >world!"
> >Setting display on it's own isn't enough.
>
> Now the script says '$XAUTHORITY=/home/jjj/.Xauthority gxmessage
> -display :0 "Hello world"' but I get:
>
> /home/jjj/Software/./Backup_script_for_Home.sh: line
> 9: /home/jjj/.Xauthority=/home/jjj/.Xauthority: No such file or
> directory
>
> I checked and the .Xauthority file is really there, and a search
> revealed that there are no other .Xauthority files or folders anywhere
> on ~/.
>
> I can only think that root is unable to look in ~/. That doesn't make
> much sense, but it's all I can think of.
>


XAUTHORITY , remove the leading $ from your command. When setting a shell
variable, just use the name. When referring to it, use the $.

In this case the variable is unset because cron runs independently of X. So
you run the command as follows:
XAUTHORITY=/path/to/file DISPLAY=:0 gxmessage

It's possible ubuntu puts it somewhere else, it doesn't need to be in your
home folder so log in to your desktop. let's set cron aside for a second
and test our commands to make sure they work. Here are the commands I used
to verify that I have everything lined up:
ben@laptop:~$ echo $XAUTHORITY
/home/ben/.Xauthority
ben@laptop:~$ echo $DISPLAY
:0
ben@laptop:~$ XAUTHORITY=/home/ben/.Xauthority DISPLAY=:0 gxmessage "hello,
world!"

See how I take the value returned by echoing the variables and used them in
the gxmessage command? It's an override, the last command can be run from
any terminal as long as you are logged in. Once you know what the Xauth and
DISPLAY variables should be set to, you can alt-f2 to get out of X, and run
any command regardless of where the shell is to pop up a window. scripts
executed from cron will always need this treatment since they are not
inherently aware of X. This changes from distro to distro, so the paths I
have on slackware are simply the upstream defaults and I would not be
surprised if other distros have their own temp folders for these auth files.






> _______________________________________________
> PLUG mailing list
> PLUG@pdxlinux.org
> http://lists.pdxlinux.org/mailman/listinfo/plug
>
_______________________________________________
PLUG mailing list
PLUG@pdxlinux.org
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to