0

How to get a screenshot of only one window from the command line if I have window id? enter image description here

I want to show a preview screen like this for a specific window with qml and pyqt5. What can I do then?

4
  • Several options, using one of the applications that has this as a cli option, using imagemagick's import or using Gdk in one of the languages. What is the context? Jan 19, 2020 at 16:35
  • @Jacob Vlijm now I added more details. What can I do with this case? Jan 19, 2020 at 17:01
  • Ah, writing a preview application? I hope I can find the time to write an answer in the next few days. In the meantime, have a look here: github.com/UbuntuBudgie/budgie-extras/blob/master/…, line 202-204 are the relevant lines. it's Vala, but the python way is similar. You can do the scaling in one step, and this is the least consuming way. Hope it is understandable. As said, If I can find time in the next few days, I'll write an answer. Jan 19, 2020 at 18:25
  • 1
    select the window using xdotool . $id I got from name .delay is optional though advisable or put a wait command in after it. . ids=$(xdotool search --desktop 0 --class "$name") and if more than one id you need to make a decision xdotool windowactivate --sync $id key --delay 100 then use screenshot of that active window gnome-screenshot -w make a script and a keyboard shortcut.
    – pierrely
    Jan 24, 2020 at 5:47

1 Answer 1

2

You can raise the relevant window with the wmctrl command and take its screenshot using the gnome-screenshot command. For example, assuming that the window id is 0x02600010, you can use:

wmctrl -i -a 0x02600010 && gnome-screenshot -w
1
  • sorry. I didn't describe what I want. Now I edited my post. Can you give me a suitable answer? Jan 19, 2020 at 17:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .