rlopez1j / xmonad

Automatically exported from code.google.com/p/xmonad
0 stars 0 forks source link

Key binding improvements #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, the use of modifier keys as the prefix key is a bit troublesome.
You can either render your Meta/Alt key useless for anything non-XMonad or
hope one of the other 3 will work out. And if you want anything else, you
get to enjoy the loving caresses of xmodmap - about which the less said the
better.

So it's difficult if not nigh-impossible to do more complex things; let's
take an avid user of GNU Screen and Emacs. Such a gal is a natural for
using XMonad; but they don't want to give up Control or Meta to XMonad, for
obvious reasons (and they use a Happy Hacker keyboard, so no Windows key).
The natural and pleasant approach would be to set the XMonad prefix key to
"C-z", analogous to "C-a".

In Ratpoison or Stump, this would be a very easy thing to do and it is
indeed often done - a simple 'escape C-z' does it. In XMonad? They are, as
best as I can figure, screwed.

This is a suboptimal situation, and needs rectification. I don't think it
can be done as an extension because the privileging of Mod1-4 seems to be
embedded all the way down into the core.

Original issue reported on code.google.com by gwe...@gmail.com on 22 Oct 2007 at 4:32

GoogleCodeExporter commented 9 years ago
Personally, I don’t find xmodmap very troublesom. With something like

$ head ~/.Xmodmap
keycode 66 = Super_L
keycode 78 = Multi_key
keycode 113 = Mode_switch
remove Lock = Super_L
add Mod4 = Super_L

you get rid of the useless CapsLock key and can use it as Mod4 for xmonad. 

(I know that this does not fix your bug and that you are right, I just added 
this as
a note to those who do want to fiddle with Xmodmap)

Original comment by nome...@gmail.com on 22 Oct 2007 at 5:13

GoogleCodeExporter commented 9 years ago
> you get rid of the useless CapsLock key and can use it as Mod4 for xmonad.

It is not useless for me at all: I have Ctl and CapsLock swapped. :)

--
vvv

Original comment by valery...@gmail.com on 22 Oct 2007 at 7:48

GoogleCodeExporter commented 9 years ago
VVV: why on earth would you want to *swap* them? Capslock is an unpleasant key 
I've
configured X to just replace with another Ctrl...

Nomeata: Yes, that might work for some configurations, but for anything 
nonstandard,
xmodmap is a bizarre relic of the '80s, and X was never very well designed in 
the
first place. And you're right, it really doesn't help this bug since I can't 
see how
you would bind the example C-z as the prefix.

---

But while I'm here, I might as well mention how StumpWM/RP solve this problem 
(begin
vague recollection of how Sabetts explained it to me). 
#They seem to somehow intercept all pressed keys and then match against a sort 
of
'root-map'. The root-map consists of a list of keys (usually exactly one key or
key-combo - as I mentioned I often saw C-z as the entry in the root-map, but I 
could
and did have the keys 'Insert' and '>' both be entries in the root-map, so I
effectively had two single key prefixes).
#When a key press is matched against an item in the root-map, the window manager
shifts over into command mode and does some other stuff like change the 
appearance of
the mouse so you know you are in command mode.
#Now in command mode, keys are intercepted again, but this time matched against 
a
different map, a top-map. This includes more normal stuff, ie a press of 'k' 
will be
matched against the function "kill" and so on.

This scheme offers much more flexibility than XMonad's, obviously. You can use 
the
modifiers, or not, you can use arbitrary keys, you can loop between keymaps (for
example, remember that I had Insert in the root-map bound to 
'enter-command-mode' or
whatever; Insert was then rebound in the top-map to 'previous', so if I wanted 
to
flip back and forth between windows all I had to do was bounce my thumb on 
Insert.
Extremely convenient, but how would you do that in XMonad? Each key press is 
its own
event, there is no state to make use of.), etc. etc.

Original comment by gwe...@gmail.com on 22 Oct 2007 at 8:15

GoogleCodeExporter commented 9 years ago

Original comment by SpencerJ...@gmail.com on 22 Oct 2007 at 10:25

GoogleCodeExporter commented 9 years ago
I may be missing something (considering three other people haven't mentioned 
it), but
does XMonadContrib.Submap do what you're after?

Original comment by m...@twifkak.com on 22 Oct 2007 at 11:28

GoogleCodeExporter commented 9 years ago
twifkak: I am not sure. It seems to add in another keymap, but not replace 
XMonad's.
Thinking about it, if I understand correctly the documentation, you could 
perhaps
insert all the normal bindings *within* a submap and as long as you deleted the
original things might work... I think I've noticed that even when the prefix is 
hit,
as long as the Mod-whatever is bound to a command, it just gets passed on. But I
would really need to mess around with it to know whether you could hack 
something up
akin to what I'm suggesting as the default.

Original comment by gwe...@gmail.com on 23 Oct 2007 at 12:24

GoogleCodeExporter commented 9 years ago
Yeh, Submap doesn't get you out of needing (modifier)key initially (hence 
*sub*map).

Original comment by allber...@gmail.com on 23 Oct 2007 at 12:27

GoogleCodeExporter commented 9 years ago
Submap is sufficient, here's what you need to do:
 - delete all of the default keybindings
 - add a single keybinding for your desired prefix key that activates a submap
 - add all the desired keybindings to your submap

I don't think we'll add this functionality to the core.

Original comment by SpencerJ...@gmail.com on 24 Oct 2007 at 6:18

GoogleCodeExporter commented 9 years ago
I'm struggling to try Xmonad because I don't have a windows key and the "loving 
caress" of xmodmap (as the original poster puts it) is not so gentle. As 
someone new 
to Xmonad and Haskell, the "sufficient" workaround is not simple at all:

 - delete all of the default keybindings
 - add a single keybinding for your desired prefix key that activates a submap
 - add all the desired keybindings to your submap

I wouldn't know how to start with implementing that. 

I even tried the "extra user-friendly" BlueTile alternative. It also assumed I 
had a 
Windows key...

Original comment by mark.sto...@gmail.com on 3 Feb 2010 at 2:49

GoogleCodeExporter commented 9 years ago
On my system, at least, my left and right modifier keys of the same type (e.g.,
"alt", "shift") are seen by X as different keys; this leaves open the 
possibility of
using one of the two for Xmonad, and the other for its original purpose.  You 
can
check by running "xev" and seeing what key code you get when you press those 
keys; if
they are indeed different, and if you are amenable to the idea (e.g., if you 
notice
you always use only the left or right version of that key), you should be able 
to
write a much simpler xmodmap than "delete and re-add everything" which gets you 
what
you want.

Original comment by korpios%korpios.com@gtempaccount.com on 3 Feb 2010 at 3:14

GoogleCodeExporter commented 9 years ago
There's a really simple way to do this!  I'm surprised the example isn't in a 
FAQ somewhere, but this issue shows up first on Google for "xmonad prefix key", 
so I'm adding the code here.

Tailor to your preference.  The tuple passed to prefixKey is a regular 
xmonad-style (modifier, keycode) tuple.  In this file, I use an unmodded Escape 
key as my prefix, and strip the modifier from the usual keybindings by setting 
modMask to 0.

So, where a keybinding used to be (modMask, keycode), I've changed it to the 
moral equivalent of [(0, xK_Escape), (0, keycode)].

Have fun, and happy hacking!

P.S. Haskell's type system rules.  As soon as I got this to compile, it Just 
Worked. :)

Original comment by kekito....@gmail.com on 11 Dec 2010 at 6:01

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I deleted the previous attachment because it had a major bug that broke mouse 
bindings.

Here's a better factored version, and also allows PREFIX-PREFIX to send the 
PREFIX char to the client window.

Original comment by kekito....@gmail.com on 11 Dec 2010 at 6:49

Attachments: