From Noah.org
Jump to: navigation, search

Xorg X-Windows X11R7

Capture screen shot of the current window

This works on `xterm` and `gnome-terminal`. It should work on any terminal that defines WINDOWID.

xwd -id $WINDOWID -silent | xwud

This is similar but saves output to a PNG file.

xwd -id $WINDOWID -silent | xwdtopnm | pnmtopng > terminal_screenshot.png

Get background color of shell

This was motivated by the desire to have Vim start with the best color scheme depending on whether the terminal has a dark background or light background. It's sort of a ridiculous thing to do, but Xterm will not report its background color.

This is a hack. I'm still working on this.

This is the fastest way I found to guess the background color of a given window. This should give average color, but it seems to be more like median.

time xwd -silent -nobdrs -id $WINDOWID | convert - -gravity center -crop 1x1+0+0 -depth 8 txt:-

Average color, Slower:

time xwd -silent -nobdrs -id $WINDOWID | convert - -colors 1 -crop 1x1+0+0 -depth 8 txt:-

This makes a Desktop icon of a window:

time xwd -silent -nobdrs -id $WINDOWID | convert - -crop 32x32+0+0 -depth 8 xpm:-

Display apps on remote X11 desktop

If you xserver was started to listen to TCP port 6000 then this will work. If your Xorg was started with the -nolisten option then this will not work. Note that running your X server this way is very insecure. This is the old-fashioned way of doing it. This was invented before they invented security.

On your server you need to allow clients to connect to your display. From a command-line run this command:

xhost +

On your client machine simply set your DISPLAY to the IP address of the server and then run your X app.

export DISPLAY=