I am using take-vector-screenshot to take a PDF screenshot.

When I launch take-vector-screenshot, I have to click a button within its window in order to begin the screenshot process. I then need to pick the window to take a screenshot of.

A button is required to be clicked to start the process

In the process of clicking this button (pictured above), the focus changes from the window which I actually want to capture. Hence the screenshot I get is of an unfocussed window, which is undesirable.

I can use wmctrl -a $WINDOW_TITLE to focus the window I want to take the screenshot of, but this doesn't work if I precede it with e.g. a sleep 3.

Any ideas how I can get this to work?


This (somehow) appears to be related to my shell.

If I run bash and then try sleep 2; wmctrl -a WindowTitle, it works fine.

Fails every time in zsh though - no idea why.

This doesn't solve the problem though: because the window still gets unfocussed when the save dialog appears. I fixed this part of the issue by forking gtk-vector-screenshot and adding calls to gtk_window_set_accept_focus(window, False);. I also removed the save dialog, so PDFs just get written to the home directory. It's a hack, but the project isn't being maintained anymore and it does the job for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.