How to Take a Screenshot on Remote Terminal Connection?


How I can take a screenshot of the desktop on the terminal? I am connecting the device via SSH.
I tried with some Ubuntu commands and pyscreenshot library, but it throws “unable to open X server” error

Thank you

$ DISPLAY=:0 gnome-screenshot

Did you try this ?

Thank you @MtHiker,

It throws
** Message: 08:12:11.316: Unable to use GNOME Shell's builtin screenshot interface, resorting to fallback X11.


Even the mesg, you may find a screenshot image in the ${HOME}/Pictures directory.

One possibility, perhaps not all that convenient, is to start Gimp on your PC host. From the “File->Create->Screenshot…” menu you can pick “Take a screenshot of a single window”, but first set “Delay” to maybe 2 seconds. 2 seconds later the cursor will change shape, and whatever you click on next will have a screenshot. You can “save as” (native xcf format) or “export” (e.g., png is good lossless format).

If you are just speaking of text and not a GUI app, then it is perhaps easy to copy and paste or “File->Save as”.

Do you have a local display connected to Jetson ?
I assume yes and it is display 0. If not it would need to be refined.

Not sure as I cannot try now, but you may also try this with gstreamer :

DISPLAY=:0 gst-launch-1.0 ximagesrc num-buffers=1 ! jpegenc ! filesink location=screenshot.jpg

This would save a screenshot of your display into a JPG file. Then get the jpg image from Jeston with scp.

1 Like

Thank you guys for your help,

@MtHiker 's gnome approach worked.
@Honey_Patouceul 's gst-launch also works but I have another gstreamer process working and that cause confiction.
I actually looking something with Python. I tried pyscreenshot and PIL’s ImageGrab libraries but it captures only a black screen. Would you recommend any other way or how can capture with these libraries without having black screen?