Tiny Core Linux
General TC => Programming & Scripting - Unofficial => Topic started by: Rich on March 19, 2013, 03:27:45 AM
-
This is a modified version of screenshot.sh that will produce a png of the window you click on. It depends on xwininfo
to run so you need to install xorg-7.(5 or 6)-bin.tcz only.
-
I forgot to mention, if you click on the desktop, it will create a screenshot.
-
Excellent! :D
One observation: the aterm from which command is executed must not overlap the window clicked on, or it would end up being included in the windowshot.
-
Hi tinypoodle
That is correct. The "picture" will be of whatever is visible on the screen inside the coordinates of that particular
window.
-
Not being Rich but just assuming you were replying to my post...
Also, I found that areas of windows outside screen borders will be painted gray.
-
very good
Two windows, one superimposed on the other.
Clicking on the rear window also captures the front.
Muy bueno
Dos ventanas, una superpuesta a la otra.
Al hacer clic en la ventana posterior tambien se captura la frontal.
(http://i49.tinypic.com/2lo3hwo.png)
-
Hi tinypoodle
Not being Rich but just assuming you were replying to my post...
Lack of sleep, copied/pasted the wrong name, corrected.
That's because imlib2_grab can only save what is painted on the screen, but since it uses the windows coordinates
and dimensions, it fills in what it can't read in gray. In fact, I once read through some of the documentaion for
imlib2_grab and I seem to recall it was mention there too.
-
Hi beroje
Glad you like it.
-
That makes all sense and still an advantage over having a full screenshot when only a window is required.
I'd assume the gray areas should be well compressible by png.
-
Hi tinypoodle
I'd assume the gray areas should be well compressible by png.
Not as much as you might think. I took the same shot as the one attached to my first post but with the window
halfway off the screen and the file size went from ~16K to ~15K. On my system the off screen section was black.
-
The semantic difference between "assume" and "test"... :P
And probably black is preferable over gray as look.
-
Hmm, I got 68Kb with an estimated quarter of window visible versus 171Kb with same full window, so I guess it may depend.
-
Hi tinypoodle
The results I got may be do to the fact that I used the editor with just the posted script in it. I slid the window to the
right obscuring the right half of the window which consisted of a lot of white space and may have already compressed
fairly well when doing a capture.
-
Such factors most likely could explain the differences.
-
Elegant. I'm using it as my default from now on, but I removed the sleep.
-
Hi hiro
Since I don't know why that one second sleep command was put in there, I didn't remove it. I though it might have
been to allow you time to move the mouse pointer somewhere out of the way, but from what I've seen, the mouse
pointer is not captured.
-
I guess in the original version it was meant for you to have some time to arrange things, like bringing the right window to the front or hiding what you invoked screenshot.sh from, but with this addition it shouldn't be needed I think.
-
Once xwininfo is invoked pointer device can't be used to arrange anything, while there is unlimited time to use keyboard before selecting window.
-
Hi tinypoodle
That may be, but the sleep command is after xwininfo has finished executing, leaving you one second before
imlib2_grab runs.
-
Ah yes, correct!
And it seems that if switching desktop within that 1 sec and the selected window does not exist in desktop chosen at time of execution imlib2_grab, then there is a popup but no screenshot saved...
-
Hi tinypoodle
Switching the desktop probably changes the root window. In order to capture the window you clicked on, imlib2.grab
needs to know its position, size, etc. I believe that involves making a series of calls to X starting with the root windows
ID to find all the child window IDs until a match is found. If the window you clicked on does not exist on that desktop,
it won't be found and nothing is captured. Even if it could be found, you would get a black (or gray) image since the
image imlib2.grab creates is of what is visible on the screen.
-
I've been using a similar script, though mine pipes xwd through a couple netpbm tools.
-
imlib2_grab not in /usr/bin/ , added local/
(http://i40.tinypic.com/2ymsgtt.png)
-
Hi beroje
Yes, that was copied verbatim from the original screenshot.sh. Maybe it would be better to omit the path altogether.
-
Would make a great extension for the repo :P
-
...or added to Xprogs to compliment " screenshot " :thumbup:
-
re: TCP 5.1, windowshot.sh
hi,
This script cannot find imlib2_grab.
Please patch xorg.
eltone
-
is the imlib2-bin extension loaded?
-
is the imlib2-bin extension loaded?
Dear Juanito:
Both imlib2-bin.tcz & xorg-7.7-bin.tcz were loaded.
Everything appears ok until attempting to find the .png in the home directory. The file never got written to disk!
Sincerely,
eltone
-
Hi eltone
Did you read replies #22 and 23? Try changing:
/bin/sh -c "/usr/bin/imlib2_grab -id $WINDOW_ID $HOME/$filename"
to:
/bin/sh -c "imlib2_grab -id $WINDOW_ID $HOME/$filename"
in the script.
-
. . .read replies #22 and 23
Dear Rich:
Your script is now fully functional, thanks!
Sincerely,
eltone
-
This script with minor modifications approved by Rich was just submitted to TC6 x86 as windowshot.tcz - coming to a repo near you! Tacky desktop icon courtesy me. Noteworthy: In addition to crisp window screenshots user can also click on desktop space to produce a nice screen grab of the entire desktop, including open windows, wbar icons, conky output, fluxbox panel.