Re: FVWM: Question regarding actions when modifier keys are held down/released
Hegel3DReloaded <[email protected]>
| Newsgroups | gmane.comp.window-managers.fvwm |
|---|---|
| Message-ID | <VF1cfPLAu9N8r7b6ghvjWjgg5hDw-_5f6eHuqvpDvh2RfGOXmzfoiySIpkPt-e3O0mHe34goY6pEeiYW2GkVoEJoZGb_EsDYyzwbRPYKf8M=@protonmail.com> |
On Wednesday, 28. August 2019 17:03, Dave Weller-Fahy <[email protected]> wrote: > Greetings, > > I've search the website, archives, wiki, and a number of configuration > websites, and have been unable to find a way to cause an action to > happen when a modifier key is held down and/or released. I'm running > fvwm 2.6.8 on CentOS 7. > > My goal is to have the following rules followed. > > Rules about keys being pressed and (possibly) held. > > - If Ctrl-Alt are pressed ... > - and if no other keys are pressed within some period of time ... > - then pop up the pager > - and if other keys (such as arrow keys) are pressed ... > - then execute some other action > > Rules about keys being released. > > - If Ctrl-Alt are released ... > - and if the pager is displayed ... > - then remove the pager > > The use case is to have Ctrl-Alt-(up|down|left|right) change desks, > but, if one wants, then holding Ctrl-Alt before pressing the arrow key > will pop up the pager so you can see the desks to which you will be > changing. Hello, I have too lasted for this feature at some point. Unfortunately, both Alt and Ctrl are modifiers and by themselves cannot have a function. I was thinking of calling IgnoreModifiers temporary in some function, but this sentence in fvwm(1) man page disocouraged me: "If you issue it when your fvwm session is already up and running the results are unpredictable." But not all is lost - probably the closest match to this functionality is the following setup which I currently use (purified <...> part of configuration). Pager is configured under name/alias "LocalPager": FvwmEvent (called as "Module FvwmEvent MainLoop") setup: <...> *MainLoop: new_desk f_ChangeDesk *MainLoop: new_page f_ChangePage <...> DestroyFunc f_ChangePage AddToFunc f_ChangePage <...> + I Test (EnvMatch infostore.pageshowrootpager 1) f_ShowLocalPager <...> DestroyFunc f_ChangeDesk AddToFunc f_ChangeDesk + I Test (EnvMatch infostore.pageshowrootpager 1) f_ShowLocalPager DestroyFunc f_ShowLocalPager AddToFunc f_ShowLocalPager + I Deschedule 131313 + I All (Iconic, "LocalPager") State 0 + I All (State 0, "LocalPager") Iconify off + I All (State 0, "LocalPager") Piperead "echo Move +$(( $[vp.width]/2-$[w.width]/2 ))p +5p" + I Schedule 1500 131313 All ("LocalPager", !HasPointer, !Iconic) Iconify on + I Schedule 3000 131313 All ("LocalPager", !HasPointer, !Iconic) Iconify on + I Schedule 5000 131313 All ("LocalPager", !HasPointer, !Iconic) Iconify on + I Schedule 8000 131313 All ("LocalPager", !HasPointer, !Iconic) Iconify on + I Schedule 10000 131313 All ("LocalPager", !HasPointer, !Iconic) Iconify on + I All ("LocalPager") State 0 False Now the keybindings part: when moving to another page or desk by ANY key binding, LocalPager will popup on the screen (top center in my case) and indicate where we are. If it doesn't get any attention, or it is left alone after 3, 5, 8 or 10 seconds, it will dissapear. I'm using Ctrl+(Up|Down|Left|Right) to move through pages of the current desk. However, if Ctrl+Menu is pressed (which is close and handy to Ctrl+cursor keys), Pager will move under the pointer for direct visual selection with mouse, no matter if it is Iconic currently or not: Silent Key Menu A C f_BringLocalPager DestroyFunc f_BringLocalPager AddToFunc f_BringLocalPager + I f_ShowLocalPager + I All (LocalPager) AnimatedMove m-5 m-6 One can even use my "double key binding" which has some Emacs-like feel, and it prevents accidental activation while typing fast something. This is a meta function, or "API" let's say. # Execute what is in $1 - $X only a second time when # function is called. Used to make double key bindings # that will prevent accidental call while typing fast. DestroyFunc f_DoubleBindKey AddToFunc f_DoubleBindKey + I Test (EnvMatch infostore.dbk_$0 1) $[1-] + I Test (!EnvMatch infostore.dbk_$0 1) InfoStoreAdd dbk_$0 1 + I Schedule 2000 InfoStoreRemove dbk_$0 That said, "Key Menu A C" can be than called as f_DoubleBindKey loc_pager f_BringLocalPager ... where "loc_pager" is part for the short lived infostore variable special only to this usage of the function. Hope this helps a bit. P. S. You can find this and lot of other functions in My "NsCDE" project of FVWM-based CDE on steroids on Github. ... one of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs. -- Robert Firth