Discussion:
FVWM: Bind key sequences
Andre Majorel
2012-04-28 10:49:02 UTC
Permalink
Is there a way to bind key *sequences* to functions ? EG
[kp-*][1] to switch to page (0,0), etc.

Thanks in advance.
--
André Majorel http://www.teaser.fr/~amajorel/
Thomas Adam
2012-04-28 10:53:26 UTC
Permalink
Post by Andre Majorel
Is there a way to bind key *sequences* to functions ? EG
[kp-*][1] to switch to page (0,0), etc.
Thanks in advance.
Define what you mean by "sequence" in more detail. You can already
bind KP_* keys.

-- Thomas Adam
Dan Espen
2012-04-28 12:25:32 UTC
Permalink
Post by Andre Majorel
Is there a way to bind key *sequences* to functions ? EG
[kp-*][1] to switch to page (0,0), etc.
The best way to bind sequences is to use a menu with hot keys.

kp-* to bring up the menu,
1 to select a menu entry that has 1 assigned as a short cut.

I actually use kp-* as a menu key and the menu goes by so fast
you almost don't see it.
--
Dan Espen
Thomas Adam
2012-04-28 12:29:30 UTC
Permalink
Post by Dan Espen
Post by Andre Majorel
Is there a way to bind key *sequences* to functions ? EG
[kp-*][1] to switch to page (0,0), etc.
The best way to bind sequences is to use a menu with hot keys.
kp-* to bring up the menu,
1 to select a menu entry that has 1 assigned as a short cut.
I actually use kp-* as a menu key and the menu goes by so fast
you almost don't see it.
Oh, that.

The solution in the FAQ is what I use (heavily modified, of course):

http://fvwm.org/documentation/faq/#3.27

-- Thomas Adam
Andre Majorel
2012-04-29 20:35:45 UTC
Permalink
Post by Thomas Adam
Post by Dan Espen
Post by Andre Majorel
Is there a way to bind key *sequences* to functions ? EG
[kp-*][1] to switch to page (0,0), etc.
The best way to bind sequences is to use a menu with hot keys.
kp-* to bring up the menu,
1 to select a menu entry that has 1 assigned as a short cut.
I actually use kp-* as a menu key and the menu goes by so fast
you almost don't see it.
Oh, that.
http://fvwm.org/documentation/faq/#3.27
Thanks folks. This makes [Pause][KP_7] switch to page (0, 0)
whether or not num-lock is on :

DestroyFunc pause
AddToFunc pause
+ I Key KP_Home A N GotoPage 0 0
+ I Schedule 1000 Key KP_Home A N -
Key Pause A N pause

DestroyFunc pause_numlock
AddToFunc pause_numlock
+ I Key KP_Home A 2 GotoPage 0 0
+ I Schedule 1000 Key KP_Home A 2 -
Key Pause A 2 pause_numlock

Note how KP_Home must be used, even though the actual event is
KP_7. There may be a simpler way but I've had enough for
tonight.
--
André Majorel http://www.teaser.fr/~amajorel/
Thomas Adam
2012-04-29 20:50:51 UTC
Permalink
Post by Andre Majorel
Note how KP_Home must be used, even though the actual event is
KP_7. There may be a simpler way but I've had enough for
tonight.
No, there isn't. It's two different keysyms, depending on whether Numlock
is used. That's expected.

-- Thomas Adam
--
"Deep in my heart I wish I was wrong. But deep in my heart I know I am
not." -- Morrissey ("Girl Least Likely To" -- off of Viva Hate.)
Andre Majorel
2012-04-30 13:27:11 UTC
Permalink
Post by Thomas Adam
Post by Andre Majorel
Note how KP_Home must be used, even though the actual event is
KP_7. There may be a simpler way but I've had enough for
tonight.
No, there isn't. It's two different keysyms, depending on whether Numlock
is used. That's expected.
What I found counter-intuitive was having to bind KP_Home even
when num-lock is on.

What would you recommend to bind [pause][pause] to [pause] ?
(I.e. to get a literal hot key, press it twice.) This does not
work :

DestroyFunc pause_numlk_off
AddToFunc pause_numlk_off
+ I Echo pause_numlk_off
+ I Key KP_Home A N GotoPage 0 0
+ I Key Pause A N pause_pass
#+ I Schedule 1000 Key KP_Home A N -
#+ I Schedule 1000 Key Pause A N -
Key Pause A N pause_numlk_off

DestroyFunc pause_numlk_on
AddToFunc pause_numlk_on
+ I Echo pause_numlk_on
+ I Key KP_Home A 2 GotoPage 0 0
+ I Key Pause A 2 pause_pass
#+ I Schedule 1000 Key KP_Home A 2 -
#+ I Schedule 1000 Key Pause A 2 -
Key Pause A 2 pause_numlk_on

DestroyFunc pause_pass
AddToFunc pause_pass
+ I Echo pause_pass
+ I Key Pause A N -
+ I Key Pause A 2 -
+ I Schedule 50 FakeKeypress press Pause
+ I Schedule 100 Key Pause A N pause_numlk_off
+ I Schedule 100 Key Pause A 2 pause_numlk_on

There is a race somewhere : without the delays, the FakeKeypress
in pause_pass triggers pause_numlk_{on|off}. But the main
problem is that Xterms don't see the KeyPress event.
--
André Majorel http://www.teaser.fr/~amajorel/
Thomas Adam
2012-04-30 13:39:56 UTC
Permalink
Post by Andre Majorel
There is a race somewhere : without the delays, the FakeKeypress
in pause_pass triggers pause_numlk_{on|off}. But the main
problem is that Xterms don't see the KeyPress event.
[.....]

Like so many programs, synthetic key events generally aren't accepted
by programs due to the inherent security implications. XTerm can be
told to accept them (allowSendEvents).

Don't rely on this.

-- Thomas Adam

Loading...