View Full Version : How launch script or command from icewm?
aleunix
06-07-2008, 11:01 AM
How launch script or command from icewm?
I would launch a script or use a plain command line to take a screenshot but i haven't find a way on icewm.
$HOME/username/.icewm/keys
key "Print" xterm -e xwd | convert - screenshot.png
I have press the Print key but don't run.
I have also tried:
$HOME/username/.icewm/menu
prog Screenshot xwd xwd
But without result.
lvlamb
06-07-2008, 07:26 PM
In ~/.icewm/menu
prog Screenshot any_icon.png xwd -out screenshot.xwd
should do it.
Then. open the ~/screenshot.xwd in ImageMagick (display).
Dunnoh if you can pipe commands under ~/.icewm/keys or ~/.icewm/menu
but should be able to call a wrapper.
aleunix
06-07-2008, 08:27 PM
Thanks it's work. :)
Also i have tried the pipe command but don't work.
Would be possible to specify the name after the capture of screen instead of using a name fixed?
This is to avoid trying to overwrite different screenshot and also to assign a meaningful name to the captured image.
Meta_Ridley
06-08-2008, 09:13 AM
You can use a named pipe (also known as a FIFO) to do this. First you create the named pipe with mkfifo pipe_name. Then send the output of the screen-capturing program to it. The safest way is to use stdout, which generally involves specifying "-" as the output file and using ">" to redirect the output to the pipe, like this,to use lvlamb's example:
prog Screenshot any_icon.png xwd -out - > pipe_name
Note that prog will freeze at this point ("blocked" in Unix parlance) until you "connect" the other end of the pipe. That part's easy:
cat pipe_name > your_screenshot.xwd.
Replace "your_screenshot" with the name you want to save it as. Once you use the cat command prog will continue. The result should be a screenshot with the name you want. It's sort of a hackish way of doing it, but it works.
If you're lucky then prog will know what to do with a named pipe, in which case the command you put in IceWM's menu will look like this:
prog ScreenShot any_icon.png xwd -out pipe_name
The cat command remains the same.
aleunix
06-08-2008, 01:27 PM
Thanks. :)
Would be possible have a workaround to do everything in one step?
Meta_Ridley
06-08-2008, 04:58 PM
To my knowledge, not if you want to give every screenshot a unique name, unless you want to use a dialog box to name the file beforehand. Otherwise giving a unique name and doing it in one step from the window manager alone are mutually-exclusive.
Of course, if anyone else knows better feel free to correct me.
aleunix
06-08-2008, 06:27 PM
.... unless you want to use a dialog box to name the file beforehand.
Would it be possible?
Everything should work from menu icem and scripts does not seem to be supported.
lvlamb
06-08-2008, 07:15 PM
make a directory ~/snapshots
you could write a one-liner wrapper as
xwd | convert - ~/snapshots/$(date -j +%Y%m%d%H%M%s).png
save this line as a file under your ~/bin directory (might need to create a ~/bin , ~/bin is in the search PATH) under any name as, "snapshot"
make this executable
chmod +x snapshot
then, just put the line in your ~/.icewm/menu file as
exec an_icon.png snapshot
date -j is OpenBSD specific (parse date without changing the clock), read man date for other OSes
aleunix
06-08-2008, 10:12 PM
When i tried to use exec on menu the voice disappear.
vBulletin® v3.7.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.