vi style control of fvwm

This has probably been discussed somewhere. What is desired is to be pointed to the information.

I would like to set fvwm up to use the Windows key to switch into and out of a control mode, much like the esc key is used in VI. Then single key commands can be used to move, scroll, switch between windows, open windows, etc. Personally I hate using the mouse, and would prefer a control mode system to one that uses meta and alt keys.

How best to do this?
Thank you.
Randy

Ok. There may be a better way of doing this, I don’t know. . . but this is how I would do it if I were to try it right now:

Set up two files with xmodmap keybindings: One that has normal buttons (a, b, c, d etc) configured, and one with “command mode” buttons (super-a, super-b, super-c etc)

Set FVWM up to run the desired functions whenever you run the command-mode keys.

Then set the Windows key to run a script that switches between the two xmodmap settings.

You might be able to do it the other way, with FVWM’s keybindings getting dynamically reloaded. But I’m not sure how to go about that one.

It never actually occured to me to run FVWM vi-style. I’m quite interested in the idea now. Keep us posted on how you get on, eh?

I’m quite new in fvwm and linux, so I’m not sure that I know what oneandoneis2 means.

What’s xmodmap? It’s not a part of fvwm?

My idea to solve the problem:

You define the “command-mode-action” and the “normal-mode-actions” for the buttons in a seperate file. With pressing ESC read the actual file in your .fvwm2rc. But normaly you have to restart fvwm then, to make the changes work…

I like the idea of an fvwm that you can use only with the keyboard like vi(m)!!

Greetings
Arvodan

xmodmap is part of X (hence the name :slight_smile: )

Combined wth xev, it’s a powerful tool that allows you to define how the buttons on your keyboard should be treated. xev tells you what the “keycode” is, and xmodmap tells X11 what that keycode actually IS.

You don’t actually have an Esc key, a Ctrl key, a Shift key, etc. You just have a hundred and some buttons that your computer is set to TREAT as Esc, Ctrl, Shift etc keys.

So when I press my Windows button, that actually signals keycode 115 (IIRC). I told Xmodmap to treat keycode 115 as F13, so X passes F13 to FVWM. FVWM is set to call a menu when F13 is sent to it, so up pops my main menu.

So if you have two files that define the same physical keys differently, setting the Windows key to toggle between them would allow you to define different uses for the same keys by making them ‘virtually’ different buttons. And without having to restart FVWM every time, too.

Does that help?

ah…now I know what you mean…It sounds very interesting…I will trie it.
I’ve some makes some advancements he could post it here?..

hmmm, but what kinds of Buttons can I send to fvwm? What I mean:
when I`m in “command-mode” and press e.g. the “a” button on my Keyboard, can xmodmap then only send an Key like “super a” “shift a” or someting like this or even a “foo bar” key to fvwm?? Hope you understand what I mean…

Greetings
Arvodan

Thank you for the solution oneandoneis2. I do not know when I will try developing and setting up a useable 2nd xmodemap as currently am working full-time and writing a thesis. Very little time for hacking. Mostly had hoped that a useable command-mode method of controlling fvwm had already been developed. It seems an obvious enough solution that I expect it has been done a few times, at least in the early days before gnome and kde. Potentially it is quite fast and flexible.

Mostly I have been using windowmaker primarily for the keyboard control, but prefer to use a virtual desktop when working on large spreadsheets. Suspect that with a bit of thinking one could develop a system that would move about the desktop quite quickly, stick, shade, full-screen, etc with command-mode control. Perhaps even split-screen, possibly book-marking useful arrangements. Also it would be a pleasure to move about and not worry whether a program might also be using a particular meta-key combination. (I noted that VI interferred with them at times.)

After freed from the thesis, when I have time to get to things again, I plan to modify a Damnsmalllinux disk to use a command-mode fvwm. It will not matter if the host mouse works well or not, or where the buttons are, or their sensitivity or . . . .

Randy

Personally I can’t help but suspect that there are easier ways of doing this than using xmodmap to redefine your keys, I suspect that one could write an Fvwm function that redefines the keys based on if a certain variable is set or not, this would, I suppose, be a lot simpler than fiddling around with xmodmap :slight_smile:

What about using the CapsLock key to toggle in/out of the command mode. Then you would just specify your bindings with and without the Capslock modifier (L).

I’ve never tried that or used the modifier, but it should work quite well without any Xmodmap drama.

And I suppose you could do the same with the scroll lock key, and combinations of those two… :slight_smile:

Thank you. That is quite practical - much better than using the Windows key. Most people seldom use the Capslock key and it is found in a very convenient and consistent position on almost all keyboards. When a Windows key is available it can be used as an extra function key. Meta-Capslock can be used to toggle between capitals and lowercase typing.

For simple tasks (such as moving a window), I use the keypad keys. They are never used before.

Thanks
Jingshao

[color=red]I have split this thead in three other threads:
[list]
[]Decors[/:m]
[]What is the best clock?[/:m]
[]Different configuration on different workspaces[/:m][/list:u][/color]

Please stay on topic and create a new thread whenever your question doesn’t fit in the topic, you shouldn’t be afraid to create new threads as long as you’ve searched for your question and haven’t found an answer… Otherwise your thread will most likely end in the Dups forum…

Cheers

First off, sorry for the bump, not that this forum is particularly loaded with new threads… And secondly, this post probably belongs in one of the scripting forums, but I didn’t want to break up the thread.

I’m new to FVWM, but the prospect of writing a control scheme styled after vi was one reason that I fetched it in the first place (although if I recall there’s a wm that offers that feature exclusively, and probably a little better than you can get it through FVWM without some hassles). This thread never really seemed to have been resolved, so I thought I should mention the easiest (and probably one of the better) ways to implement this rc.
The basic design is one of various self-contained, generic functions that represent possible states of the interface; the key hooks themselves specifying the state, and not some variable as theBlackDragon was pondering.

So, for your grokking pleasure, a few excerpts of my rc vi implementation (code-named castrati, for obvious reasons :wink: ).

First of all, an inital state should be set-up, much like the inital state of vi:

DestroyFunc Func_BasicMode
AddToFunc   Func_BasicMode
        + I Func_Clearkeys
        + I Key K A L Direction North (AcceptsFocus) Focus
        + I Key J A L Direction South (AcceptsFocus) Focus
        + I Key H A L Direction West (AcceptsFocus) Focus
        + I Key L A L Direction East (AcceptsFocus) Focus
        + I Key Escape A L Beep

DestroyFunc Func_Clearkeys
AddToFunc   Func_Clearkeys
        + I Key K A L -
        + I Key J A L -
        + I Key H A L -
        + I Key L A L -

Func_BasicMode

Of course, just selecting windows with the H/J/K/L keys doesn’t make it a vi interface, does it? Of course not, so an expansion is an order. Here is where this design really shines, as expansions are fairly trivial (aside from Func_Clearkeys). Lets define a command to delete a window in a selected direction, somewhat like vi’s kill command, d. In order to do this, a new mode will have to be declared that uses Direction to perform a command based on the user’s input, and then we need to expose this mode with a new basicmode command:

DestroyFunc Func_DoThereMode
AddToFunc   Func_DoThereMode
        + I Func_Clearkeys
        + I Key K A L Func_Singleshot "Direction North $0"
        + I Key J A L Func_Singleshot "Direction South $0"
        + I Key H A L Func_Singleshot "Direction West $0"
        + I Key L A L Func_Singleshot "Direction East $0"
        + I Key $1 A L Func_Singleshot $0
        + I Key Escape A L Func_BasicMode

DestroyFunc Func_Singleshot
AddToFunc   Func_Singleshot
        + I $0
        + I Func_BasicMode

AddToFunc Func_BasicMode
        + I Key D A L Func_DoThereMode Delete D

AddToFunc Func_Clearkeys
        + I Key D A L -

Of course, having only read the FVWM manpage yesterday, I’m sure there’s some shortcut I’m missing, and some optimizations; but I can’t imagine it being much more maintainable than that.

One final note from experience: xmodmap is definatly not the solution here, as you can fairly easily screw up the keymapping if you don’t take special care in handling its input and output, making your X session completely unusable.

It looks interesting…I dont understand every thing you do, but I will try it.... Im still new to fvwm and don’t know the functions very well…
You sayed that these are only an few parts of your .rv? What vi-styled shourtcuts, have you definde? Perahps you could post your .rc?

Greetings
Arvodan

Well, actually, I only starting writing it yesterday, just before I saw this thread. So that’s a good majority of it, aside from a few extra modes and convenance functions. But if you’re interested, I’d be happy to post it once its mostly complete.

I’d be interested to see it when you’re done. I don’t know if I could stand to use it, mind you, but that doesn’t mean I wouldn’t want to play

I’ve been trying to think what I’d expect different keys to do if I had vi bindings:

[code]G - Last Page on Last Desktop
H - First Page on Current Desk
nG - Last Page on desk n - with zero meaning first page/first desk
‘’ - jump to previous page and desktop
mc - mark desktop (and window?) using letter c

^B - down a page
^F - up a page[/code]

Hmm - we have a second dimension to deal with here. We could use ^ and $, but I think I’d be tempted to write

^H - Left a page ^L - Right a page

And I’d overload the keys so that if you pressed them over a window they moved the window and not the viewport. Or maybe the window and the viewport together.

OK- so I’m stuck waiting for someone and I’m bored. I admit it.

Here is my solution to this problem:

###
# FvwmViMode: Vi Mode for Fvwm.
#
# First line toggles flag to 1 or 0 (1 in, 0 out)
# Second line emit a beep if in vi mode. Some extra work can be done here to 
# get some visual feed back.
# Remaining lines set or unset hotkeys.
# 
# Jingshao Chen 
#

DestroyFunc FvwmViMode 
AddToFunc FvwmViMode 
+ I PipeRead 'if test $[flag] -eq 1; then echo SetEnv flag 0; else echo SetEnv flag 1; fi;'
+ I PipeRead 'if test $[flag] -eq 1; then echo Beep; else echo Nop; fi;' 
+ I PipeRead 'if test $[flag] -eq 1; then echo Key j A N Move; else echo Key j A N -; fi;'
+ I PipeRead 'if test $[flag] -eq 1; then echo Key k A N Resize; else echo Key k A N -; fi;'
+ I PipeRead 'if test $[flag] -eq 1; then echo Echo set more keys; else echo Echo unset them ; fi;'

###
# Now set the initial value and bind FvwmViMode to a key
#
SetEnv flag 1
Key F5 A N Function FvwmViMode

Enjoy

Jingshao