Subject: FVWM: Run applicition after key release

From: [email-masked]
Date: Fri, 25 Feb 2005 00:49:03 +0800

hi,all
I want the applicition to be run after the key was release in key binding.
for example,I have define this key:

key	X	A	M	Exec exec	xterm

When i press alt,then press X for a long time,it will appear many many 
many xterm windows.

So what i want is :
if press alt,then press X,nothing happened,
when release X,the xterm running..

so if it is possible with fvwm?
Thanks for any suggestion.
-- 
Nothing for happy.
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Dan Espen <[email-masked]>
Date: Thu, 24 Feb 2005 12:54:09 -0500

> When i press alt,then press X for a long time,it will appear many many 

You get many windows because X will generate press/release events
for keys held down for whatever you set the key repeat delay to.

To Fvwm, it looks like you hit the key many times.

-- 
Dan Espen                           E-mail: [email-masked]

---

From: Thomas Adam <[email-masked]>
Date: Fri, 25 Feb 2005 00:14:28 +0000

> To Fvwm, it looks like you hit the key many times.

Indeed.  I suppose you could kludge the delay:

Key  X   A   M  Schedule 1000  exec xterm

While this will delay the execution slightly, holding down the key
combination will still  result in the xserver queing the key press
events -- but the rate of xterms launced might diminish as a result.  :)
Try it and see.

-- Thomas Adam

-- 
I know nothing, and understand even less.

---

From: Stephen Dennison <[email-masked]>
Date: Fri, 25 Feb 2005 09:42:14 -0500

> events -- but the rate of xterms launced might diminish as a result.  :)

I liked this solution, so I expanded it a bit to better match the
original request.  I created the following:
#===begin config changes for sample 1===
Key X A CM CarefulOpen xterm -bg black -fg green
Key Y A CM CarefulOpen firefox

#Set the following variable to the delay in ms to prevent additional windows
#from being opened for the duration of that delay
SetEnv open_delay_ms 5000

DestroyFunc CarefulOpen
AddToFunc CarefulOpen
+ I PipeRead "echo 'Test ( \!\$\[dont_open_$0\] \) DoOpen $*'"
+ I PipeRead "echo SetEnv dont_open_$0 True"

DestroyFunc DoOpen
AddToFunc DoOpen
+ I Exec exec $*
+ I Schedule 5000 PipeRead "echo SetEnv dont_open_$0 False"
#===end config changes for sample 1===
In this sample, holding ctrl+alt+x will only allow one xterm per five
seconds of holding the key down.  So if you hold the combo down for
only 2-3 seconds, you will only get one xterm - and it gives you that
xterm immediately.

Unfortunately this has a small limitation, if you try it with the same
command, but different argument lists, it can't distinguish between
the two of them.
ie, the following two would look like a match:
Key X A CM CarefulOpen xterm -bg black -fg green
Key Y A CM CarefulOpen xterm -bg white -fg black
Hit either of them, and you'd have to wait 5 seconds before you could
hit the other.  This is because the match is done off of just the
first argument.

So I made this more generic solution as well:
#===begin config changes for sample 2===
Key X A CM CarefulOpen_xterm
#Set the following variable to the delay in ms to prevent additional windows
#from being opened for the duration of that delay
SetEnv open_delay_ms 5000
SetEnv safe_to_open_xterm True

DestroyFunc CarefulOpen_xterm
AddToFunc CarefulOpen_xterm
+ I Test ($[safe_to_open_xterm]) DoOpen_xterm

DestroyFunc DoOpen_xterm
AddToFunc DoOpen_xterm
+ I SetEnv safe_to_open_xterm False
+ I Exec exec xterm
+ I Schedule $[open_delay_ms] SetEnv safe_to_open_xterm True
#===end config changes for sample 2===

If anyone is feeling more adventurous, they could take sample 1 and
escape out the entire argument list to generate a suitable variable
name instead of how I have only used the first argument, and that
would eliminate the need for copying sample 2 and creating 2 functions
for each new command.  Could probably replace my 'Exec exec $*' in
sample 1 with PipeRead "echo $*" and then it could be bound to menus
and functions instead of just stuff to be exec'ed.

--s.r.d.