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.)
X" suffix will specify a specific screen/device. So, DISPLAY=:0 usually means "The GPUs in the system." DISPLAY=:0.0 means "The first configured screen/GPU" - I think it's actually screen, but with one screen configured per card, it's the same. DISPLAY=:0.1 means "The second configured screen/GPU."
Explicitly setting DISPLAY=:0 is usually a way to access a machine's local display from outside the local session, such as over a remote access or from a cron job.
The DISPLAY variable is used by X11 to identify your display (and keyboard and mouse). Usually it'll be :0 on a desktop PC, referring to the primary monitor, etc. If you're using SSH with X forwarding ( ssh -X otherhost ), then it'll be set to something like localhost:10.0 .
If you use an X Window System shell window such as Xterm, you must set the DISPLAY environment variable to point to the IP address and screen number of the system you are using.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With