How to take a screenshot of a window that is not visible in batch mode?
What have I tried so far:
- import from imagemagick reports an error for both window id and window name - scrot doesn't accept a window id as argument - maim and xwd don't take the screenshot if the window is not visible (it's on another workspace, not the active one, i'm using vanilla dwm) Note: I take window id and name from the output of wmctrl -l |
Maybe make window sticky, then unstick it with wmctrl?
Not tested (wmctrl not installed here) Code:
wmctrl -i -r <window id> -b add,sticky |
I can get this to work with my dual monitor setup with separate screens on Monitor0 and Monitor1.
From a terminal on Monitor1, I can capture an image from a window displayed on Monitor0 with Code:
import -display ':0.0' -window 0x1600059 ~/Desktop/wsnapshot.png Quote:
|
Quote:
|
Quote:
Quote:
|
You can't take a screenshot of a window that does not exist.
If the window is not visible then there is no window. Maybe you should explain further what you are wanting. To capture the output form a running program/process? Screenshot is just that, a picture of something that is on the screen. Maybe you are wanting something else. I'm trying to figure out what you are doing. A shot of a minimized window? Or do you have a dual monitor setup with one monitor unplugged? Why isn't the window visible? Or a window that is behind another window? What? |
Quote:
|
If you are wanting to capture a window on another work space, then give yourself a pause so you can make it active.
Code:
sleep 5 && scrot -u https://askubuntu.com/questions/3030...nactive-window https://unix.stackexchange.com/quest...tive-workspace |
Quote:
|
Quote:
|
Quote:
I can't do anything else, because I need to take lots of screens for hours. That's why I want to run that window in the background (another workspace) and I need a way to take screenshots of it. Quote:
|
Quote:
|
Quote:
|
Technically changing window state to sticky does not move it. On the contrary, it's a flag that tells to window manager to let the window stay in place (stick on screen) while other element can move (viewports...)
Maybe dwm doesn't support this feature though (I never used it) |
This is the command that I use to take window snapshots.
Code:
import -window $(xwininfo | awk --non-decimal-data '/Window id/{printf "%d", $4}') ~/Desktop/wsnapshot.png I actually usually use it from a script behind a right click menu entry. PS - The conversion of the window id from hex to decimal does not appear to be necessary for 'import' any more. |
Sorry - The last post is a manual technique, but the OP appears to want an unattended scriptable solution.
|
Quote:
|
The problem is that when window is in another workspace, it's not displayed so its pixels are not in current display memory. At this point no screenshot can be made until you switch to the workspace when window resides and the pixel are drawn to the screen
|
Quote:
|
Data content yes but to get a graphical view you have to draw lines, colors, points etc on screen
I mean screenshot programs don't draw from evaluated data, they copy screen pixels in a file |
Screen capture programs assume that they need to access the active buffer.
So in my dual monitor setup I can access the active buffer on the alternate display. With a single screen, the only method that I can conceive that could create an alternative active buffer would be to use Xnest to create a second Xserver. I have played with Xnest, but cannot offer any advice for this use case. |
Another idea would be to put the window temporarly in the same workspace but under a background image which would give the illusion of a non visible window
|
Just got this to work on my little netbook.
I started a nested session running Windowmaker with Code:
exec xinit /usr/bin/wmaker -- /usr/bin/Xephyr :1 -screen 1000x500 Code:
import -display ':1.0' -window 0x1000013 ~/Desktop/wsnapshot.png |
Quote:
|
1 Attachment(s)
From my quick testing, it does not work the opposite way unless the window to be captured is in the same workspace.
I can do Code:
import -display :1 -window 0xe00013 ~/Desktop/test1.png but Code:
import -display :0 -window 0x2200058 ~/Desktop/test2.png The attached screenshot may clarify. |
@FlinchX, just curious did you try the commands in post #2 ?
|
Quote:
|
No problem, I was wondering if it could work (not having the possibility to test it myself)
|
Quote:
Code:
$ wmctrl -i -r 0x01800003 -b add,sticky |
Ok, it's seems dwm doesn't support sticky feature. I was worth a try though
And what about (say window is on workspace 2 and you work on workspace 1 Code:
wmctrl -i -r <window id> -t 1 |
Quote:
Code:
$ wmctrl -d |
Quote:
Code:
$ exec xinit /usr/bin/glxgears -- /usr/bin/Xephyr :1 |
What about open window in same workspace but put it out of screen view?
Code:
wmctrl -i -r <window id> -e 0,-2000,-1,-1,-1 |
Quote:
|
Code:
exec xinit /usr/bin/glxgears -- /usr/bin/Xephyr :1 Here: '/usr/bin/wmaker' starts WindowMaker '/usr/bin/startxfce4 starts XFCE 'usr/bin/startfluxbox' starts fluxbox '/usr/bin/startfvwm2' starts FVWM. From within the Xephyr session, glxgears works for me. |
Quote:
After this command Code:
exec xinit /usr/bin/startfluxbox -- /usr/bin/Xephyr :1 |
Are you being deliberately perverse?
If you want to break things then use rxvt (recently removed from Slackware-current). If you want to use the common denominator then use 'xterm'. If you do not want to configure fluxbox, then start your preferred dwm. This is now your problem. You have been offered two viable solutions that will work with a modicum of effort on your part. Your posting history be damned! |
All times are GMT -5. The time now is 07:44 AM. |