Screen grab from the back end?
June 22, 2006 8:59 PM   Subscribe

Can I get a screenshot of the GUI desktop from an ssh login?

If I'm connecting to a linux (Ubuntu, if it matters) machine over ssh, and that machine also has me logged in to a gnome session, is there any way to grab a screenshot of the gnome session?
posted by pompomtom to Computers & Internet (5 answers total)

If you're logging in remotely, you'll have to set your DISPLAY variable to be the local X server by prefixing whatever screenshot command you use with DISPLAY=:0.

The classic X screenshot program is xwd. To tell it to capture the whole screen, give it the '-root' option:
$ DISPLAY=:0 xwd -root -out screenshot.xwd

xwd has its own esoteric format, which you can convert into somthing useful with imagemagick's convert utility:
$ convert screenshot.xwd screenshot.png

There are probably nicer command line screenshot programs out there that can write to normal file formats directly, but xwd is pretty much guaranteed to already be on any system with X (curously, it's not included with MacOS's X11 package).
posted by zsazsa at 9:31 PM on June 22, 2006

Well, if you have ImageMagick's convert program to convert .xwd to something else, you also have it's import program which can grab directly to almost any format. For Example
$ import -display :0 -window root grab.png
(used another way to specify which display to use as well. Either way should work fine.)
posted by rpn at 11:47 PM on June 22, 2006

Thank you everyone. I haven't cracked it quite yet - I'm getting an image but it's garbage. I'm thinking perhaps the screensaver is a problem. Will turn that off tonight and do a bit of testing from home.

Thanks again. You guys rock.
posted by pompomtom at 12:12 AM on June 23, 2006

You can stop the screensaver from the command line:
$ xscreensaver-command -deactivate
Make sure you've set DISPLAY to the correct place though! ssh may be tunnelling the X connection for the display in front of you (if you're using one).
posted by pharm at 3:14 AM on June 23, 2006

« Older Who's the next hot designer?   |   Why is my cat so lovey-dovey all of a sudden? Newer »
This thread is closed to new comments.