Why is $DISPLAY sometimes :0 and sometimes :1
Asked Answered
D

1

8

I'm using xmacro to record keyboard shortcuts, which requires a $DISPLAY to replay on. But, sometimes my $DISPLAY is :0 and sometimes :1, so every time that happens I have to change the value manually. Why does it keep changing, and is there a way to set the $DISPLAY value to either :0 or :1 permanently? (I can export DISPLAY=:0 in one terminal, but that doesn't change the value of $DISPLAY in new terminals.)

Dissatisfy answered 18/1, 2013 at 8:27 Comment(0)
P
8

The number identifies the display ("a collection of monitors that share a keyboard and mouse")

:0 is usually the local display (i.e. the main display of the computer when you sit in front of it).

:1 is often used by services like SSH when you enable display forwarding and log into a remote computer.

It can also be modified by startup scripts which try to "fix" it. To find out whether this is happening, run

grep DISPLAY ~/.??*

.??* is a trick to get all dot files without .. and . (parent and current folder).

If that doesn't print anything, check /etc/profile, /etc/bash* and /etc/bash*/* in a similar manner.

I couldn't find a useful manual for xmacro but most X11 application support the option -d or -display to override $DISPLAY.

If this doesn't work, create xmacro.sh with this content:

 #!/bin/bash

 export DISPLAY=:0
 exec xmacro "$@"

Now invoke the tool with xmacro.sh and it should always work.

Preposterous answered 18/1, 2013 at 8:42 Comment(3)
On a big-iron machine you could have dozens of DISPLAY devices sharing one CPU and X "server". (The X client vs server terminology is confusing, so I'm not even trying to be correct.)Proxy
An X client is an application that sends rendering commands to an X server. An X server is something that can execute those rendering commands. What's confusing is that the X server often runs on the PC under one's desk while the X client sometimes runs on some remote server or locally.Preposterous
Yeah, I didn't want to look that up again, but there you are (-:Proxy

© 2022 - 2024 — McMap. All rights reserved.