X11 tips and tricks

X11 is the graphics server used by Linux, Xfree86 used to be the most widespread, now x.org seems more common. These are a few hints I have used.

Launching an application on a remote screen

Authorise the X server to accept connections form your other machine. (Rememver the server and client are the opposite way round to what you expect, the server is your machine with the display and the client is the machine attempting to make the connection.)

Add an .xinitrc to your home dir, use xhost to to allow this:-

xhost +<youripaddress>

To run the x11 app, export the $DISPLAY variable with the command:-

DISPLAY=<ipaddress>:0.0 /path/to/command

ipaddress is the server address, ie. the machine with the display attached.

Probably a better way and more secure is to ssh from your server machine to the client and allow ssh to set up the X forwarding in a secure channel:-

ssh -l username -X <ipaddress of client)

When you launch an app, eg. xterm, it will display on your local screen.

xset

xset used for setting x parameters, I have used it for setting font paths, eg.

xset +fp tcp/xx.xx.xx.xx:7100

7100 is the port of the font server on the remote host.

xnest

Xnest runs a new X session inside an existing one. I use it to get a desktop from a remote machine, usually a Solaris box at work, eg.

Xnest :1 -query xx.xx.xx.xx &

The :1 says which X session to connect to, -query invites a login on the remote host. If your current machine doesn't have the correct fonts for the remote machine to use, typically you will get a login box, bat after correct passwords are entered, the remote host will invite another login. This can be solved by using xset to set the font path as above. Not all machines run a font server.

Screen Capture

Screen Capture, xwd (X Window Dump). xwd write to std out, but the -out switch allows a path to a file to be specified. To take a screen shot of an individual window, use:-

$ xwd -out /tmp/window.png

If you want to capture the whole root window, use:-

$ xwd -root -out /tmp/screen.png

xwd seems to support several file types.

 
rb/x11.txt · Last modified: 04/08/2023 12:50 by andrew