I often need to take screenshots of windows that are larger than the currently shown desktop. I'm on Ubuntu 11.04, gnome-about
says Version: 2.32.1; compiz --version
says Compiz 0.9.4.0 -- and I have four virtual desktops/workspaces, which are arranged as such:
The above images were obtained by moving into each separate workspace, and taking a screenshot via PrintScreen key - that is to say, gnome-screenshot
. (I am aware that there are better ways of obtaining firefox
shots, like the "Page Saver" addon - the above is taken simply as an example of a generic oversized window).
EDIT: I'm apparently using the wrong nomenclature here (found via xorg - Get current Virtual Desktop - number/name/tag/id? - Unix and Linux) - it turns out, in the above example, I still have only one workspace; what is changed, instead, is the viewport - this is what wmctrl -d
shows on each of the "virtual desktops":
$ wmctrl -d 0 * DG: 2048x1200 VP: 0,0 WA: 0,1 1024x598 Workspace 1 $ wmctrl -d 0 * DG: 2048x1200 VP: 0,600 WA: 0,1 1024x598 Workspace 1 $ wmctrl -d 0 * DG: 2048x1200 VP: 1024,0 WA: 0,1 1024x598 Workspace 1 $ wmctrl -d 0 * DG: 2048x1200 VP: 1024,600 WA: 0,1 1024x598 Workspace 1
so to switch between "virtual desktops" from the command line, I should in fact change the "viewport", as in:
wmctrl -o 1024,0
Obviously, moving to each virtual desktop, taking a screenshot and stitching them together - and finally cutting the application window - is a bit tedious, so I was wandering if there was a tool (preferably command line) that would allow me to pick a window that is larger than the current desktop, and takes a screenshot of its entire contents, in one go. There could be two scenarios here as well:
- A larger-than-desktop window is moved so it takes up space on several virtual desktops (like the images above show)
- A larger-than-desktop window is moved outside of the total size of all virtual desktops (from the perspective of top-left desktop in composition above, imagine moving the application window towards the top-left, and outside of desktop area - as opposed to it being moved bottom right as shown above)
The first case is possible, if not in any other way, then manually (as I did it above) -- and for the second case, I guess it should be possible for an application to either "move" the window briefly to the total all-desktops area - or create a "virtual" graphics context not shown on screen, and render the window there (although, I don't know enough details to know for sure).
I have tried the following tools so far:
gnome-screenshot
xwd
scrot
import
(ImageMagick)
and they will all capture just a "corner" of the entire application window, which is shown on the current desktop (in a situation as shown above). When trying to capture "root" or "full-screen", all of these capture just the currently rendered desktop (not the total area of all virtual desktops).
I also tried shutter
(0.87.2 Rev.1071), and while I've found information that from version 0.86.4 onwards, "you can capture all virtual desktops now. Shutter will go through all of them, take a picture of every one and compose them into a one large screenshot" - I did give a try clicking on "Capture all Workspaces" - but it only takes a shot of the current workspace/desktop; window captures are likewise cut at the limits of current desktop (or fail with "Error while taking the screenshot: Maybe mouse pointer could not be grabbed or the selected area is invalid." if the window fully sits in a virtual desktop other than the current one).
Then I read that there is a screenshot plugin for compiz
- and since here compiz
manages the virtual desktops, I thought it could handle the total area - but there are no settings there (in CompizConfig settings manager), but: "Enable plugin", an output directory, and a button to enable and set hotkeys for "Initiate rectangle screenshot" -- and since apparently only thing you can do is drag with the mouse to specify a rectangular area, I doubt that plugin would help capturing the total area in one go.
Thus, I'd like to ask for some suggestions about tools, that can:
- Capture the total area (all workspaces/virtual desktops) in one go; or
- Capture the total area of the selected window, even if it is pushed outside of the currently rendered desktop (also in one go)
I would prefer something that deals with this stuff in memory - I myself could come up with something worse: such as a bash
script that sends keystrokes to change desktops (or just via wmctrl
), and takes individual screenshots there -- but that would be a pain to use, especially since I'd be visually exposed to the "desktop switching" while the screenshot is being captures... If not any complete programs, suggestions for C/Perl/Python APIs that can access bitmap data on all/any virtual desktops would be great too.
Ok, found this for X windows:
FVWM Forums • View topic - Thumbnailing a Window on another Viewport
So, I guess that means what I want is impossible? Although there are two workarounds:
xrandr
to increase the virtual size of (each of the four) viewportsThis is what works for me - first query to see which output you want, then execute:
... see also X/Config/Resolution - Ubuntu Wiki
xvfb
for virtual renderGot this via x11 - Remote offscreen rendering - Server Fault, also see Xvfb - Wikipedia, the free encyclopedia for examples. This is what worked for me - each command goes in own terminal (as some of them are meant to be services)
The problem here is that not all parts of the OS are initialized - so there are no window decoration, and only basic X fonts; although, apps may find their own fonts, as seen below:
xvfb
looks almost ideal to me - since I could basically set up an "invisible" environment, as big as I want, and take screenshots directly from it (usingxwd
). The problem is that I cannot have a window on "my" DISPLAY=:0, then switch it to the 'virtual' DISPLAY=:1 for screenshotting, then bring it back to DISPLAY=:0. Then one must set up an application specifically forxvfb
; and if so happens you need more size - then the whole chain above needs to be restarted.On the other hand, I find working with 4 workspaces and large viewports (shwere the mouse moves you around within a viewport) a bit confusing - then again, can change the size there on the fly and nothing needs to be restarted; and plus I can use any of the usual screenshot tools (but I'd still have to switch viewports).
Needless to say, I'd still love to hear about a possible command line solution that could do this kind of screenshotting in one go
:)
On my FreeBSD workstation I created a bash script to do the captures of multiple virtual workspaces then run the results through ImageMagic 'montage' to stitch them. Here is the bash script:
Here is the command I run in the ~/capture/ directory to stitch them together:
Obviously one would change the -tile and -geometry for one's own system. ;)
One needs to have installed bash, maim (or equivalent), xdotool, and ImageMagick montage for this solution. HTH