key bindings that toggle

Hello,

I just started using fvwm and I have a couple of questions regarding key bindings.

I figured out how to change the keyboard layout through a menu:

Exec exec setxkbmap -layout gb (for example to switch to UK keyboard)

and how to lock the screen through a menu:

Exec exec xscreensaver-command -lock

However what code to I need in order to execute both of them at the same time when I press Alt+F12 or some other keyboard shortcut, so that the keyboard goes back to UK layout and the screen is locked?

Also what code do I need to write in my config file in order to toggle between two keyboard layouts using Ctrl+Alt combination anywhere on the screen?

Thanks a lot in advance

Use a function.

DestroyFunc SomeFunc
AddToFunc   SomeFunc
+ I command1
+ I command2

Key blah C SomeFunc

Well, there’s a few ways you can do this. You could use SetEnv and keep a toggle that way, as in:

SetEnv A 0

DestroyFunc SomeFunc
AddToFunc  SomeFunc
+ I Test (EnvMatch A 0) Exec exec stuff
+ I TestRc (NoMatch) Exec exec somethingelse
+ I Test (EnvMatch A 0) SetEnv A 1
+ I TestRc (NoMatch) SetEnv A 0

Or, if there’s some determinable output from the command you use to switch between layout, use that.

– Thomas Adam

thanks a lot!