How to use tiling window managers with winkeyless keyboards?

User avatar
Lustique

25 Jun 2018, 11:41

Hi everyone,

as far as I know there are a quite a few Unix/Linux people here that might use both old(er)/winkeyless keyboards and a tiling window manager. Thus, I thought I should try my luck here, after I tried to get help on reddit and unix.stackexchange.com, to no avail. I hope it's not off-topic:

I currently use a tiling window manager (xmonad, to be precise, but it probably doesn't matter), and for that I need a dedicated key on my keyboard to control my window manager. Anyone who has ever used one of those window managers (like awesome, i3, bspwm, dwm, ratpoison, spectrwm, xmonad, etc.) probably knows what I'm talking about. Whenever I'm using a keyboard with winkeys, I just use my left windows key (the right Windows key is ‘Compose’), because that's not getting used otherwise. If my keyboard doesn't have any Windows keys, I'm at a loss, though. In the past, I used a combination of control + alt as my WM control key, but as I later found out, this is a rather stupid idea if you're using, e.g., Emacs at the same time…

How do you guys do it? I already thought about using my Escape key (Escape when tapped, Mod4/‘Windows key’ when held), but apparently that doesn't work or isn't possible. I already asked about this on unix.stackexchange.com (see here) without any replies or upvotes, and also on reddit without any useful replies (because things like using my Capslock key for that, and similar things are out of the window (see question on Stackexchange)), so you're kind of my only hope, now. :oops:

User avatar
AMongoose

25 Jun 2018, 11:48

I'm on i3 and even when I have a winkey i keep it as that and use capslock as my wm mod.
I guess it would depend on what keys you use for commands, I'm not familiar with xmonad, capslock works well for i3 because all the most used commands are on the right hand.

andrewjoy

25 Jun 2018, 13:06

I always remap caps lock if i don't have a winkey.

Also i3 for the win ! as much as i would like to use dwm its just too hardcore for me, would it kill them to have a config file ?

User avatar
Laser
emacs -nw

25 Jun 2018, 14:27

StumpWM user here, but my keyboards have a super/win key.

I use caps lock as the left ctrl - this means the left ctrl in the corner of the keyboard would be always free to be remapped to a win/super key instead.

EDIT: Did you try https://github.com/alols/xcape ? (Your Linux distro may have it as included/official package)

User avatar
Dingster

25 Jun 2018, 16:34

I use i3 and just have "set $mod Mod1" for alt. (Mod4 = win, Mod1 = alt). Also "setxkbmap -option caps:super" makes the caps behave like a winkey, but I've had issues with it. Just add "exec --no-startup-id setxkbmap -option caps:super" if you use i3, should work :mrgreen:

User avatar
Lustique

25 Jun 2018, 18:31

AMongoose wrote: I'm on i3 and even when I have a winkey i keep it as that and use capslock as my wm mod.
I guess it would depend on what keys you use for commands, I'm not familiar with xmonad, capslock works well for i3 because all the most used commands are on the right hand.
Yes, Capslock would work well, inasmuch as most commands are on the right in xmonad, as well. The problem, however, is that while I currently use the QWERTZ layout (i.e. German ISO), I might switch to the Neo layout in the future, and there Capslock is used as the left modifier to use layer 3. So I can't really use Capslock for my Window manager.
andrewjoy wrote: I always remap caps lock if i don't have a winkey. […]
See above. :(
Laser wrote: StumpWM user here, but my keyboards have a super/win key.

I use caps lock as the left ctrl - this means the left ctrl in the corner of the keyboard would be always free to be remapped to a win/super key instead.

EDIT: Did you try https://github.com/alols/xcape ? (Your Linux distro may have it as included/official package)
See above. :(²

Yes, I already tried something like this. I thought it might be a good idea to use Escape as an addtional modifier, because I don't think that I ever have to hold Escape down for anything. The idea was that I could retain normal Escape key behaviour for tapping by using xcape. I wrote a bit about what I tried in the unix.stackexchange question that I linked. For whatever reason, when I tried to set Escape to Mod4, I also set the ‘y’ key to Mod4, and I still have no clue why that happen{s,ed}.

I also don't know how well this would work in practice if I got it to work. Since I also use vim from time to time, an unresponsive Escape key would be almost as bad as a non-functioning Alt key in Emacs…
Dingster wrote: I use i3 and just have "set $mod Mod1" for alt. (Mod4 = win, Mod1 = alt). Also "setxkbmap -option caps:super" makes the caps behave like a winkey, but I've had issues with it. Just add "exec --no-startup-id setxkbmap -option caps:super" if you use i3, should work :mrgreen:


Since I use Emacs quite often, remapping the Alt key would not work out for me, I'm afraid. ;) Using Capslock for Mod4 would not work out, either (see above).

User avatar
Laser
emacs -nw

25 Jun 2018, 20:09

The *other* solution would be to place a Hasu converter (ps2->usb (cheaper) or usb->usb) between your keyboard and the PC - in this way, you can use the TMK firmware to map the keys as you wish (fully programmable keyboard), including "dual-role" keys, so that the OS sees them already as the key codes you want.

davkol

26 Jun 2018, 19:37


User avatar
Lustique

04 Jul 2018, 17:03

‘Update’: I just tried to remap my escape key to Super_L (via keycodes; escape is keycode ‘9’), and then just made my Super_L a Mod4 again. Obviously, this just removes my escape key, which doesn't help and prevents me from using xcape with it, but while both Super_L and my escape key were mapped to Mod4, and my ‘y’ stayed a simple ‘y’ key, my ‘9’ now puts out ‘9z’ and momentarily switches from ‘QWERTZ’ to ‘us’ and back…

Is keyboard configuration on Linux really such a buggy PITA, or am I just retarded?
Laser wrote: The *other* solution would be to place a Hasu converter (ps2->usb (cheaper) or usb->usb) between your keyboard and the PC - in this way, you can use the TMK firmware to map the keys as you wish (fully programmable keyboard), including "dual-role" keys, so that the OS sees them already as the key codes you want.
Well, I really hoped I could achieve this software-wise, especially as Hasu converters aren't exactly cheap… :(
davkol wrote: Have you seen DreymaR's Extend layer? (Or other alternatives?)

Image
I hadn't before, but I'm not interested in Colemak, to be honest. Both of the layouts you linked also seem to be made for ANSI keyboards, of which I have none. All my keyboards are ISO.

davkol

04 Jul 2018, 17:46

It has little to do with Colemak besides being hosted on a Colemak forum by a Colemak advocate.
The Extend mappings are mostly positional so they'll work with any layout – even if some keys like A and ZXCVB might be easier to remember using Colemak or QWERTY.
It isn't restricted to ANSI either:
  • the main modifier is in the Model M's Caps Lock key position
    Instead of an extra hardware key, the Extend mappings can use any key really as that extra "Fn"/Shift-type modifier, but usually it's CapsLock that gets the honor.
  • the second symbolic chart shows an ISO layout
    Image
    Symbolic chart of my Extend mappings. Greens, navigation; blue, mousing; orange, multimedia; gray, system/misc.
    World/ISO board showing Windows mappings with MouseWheel R/L keys. [1st image: US/ANSI board with Linux mappings (missing the <LSGT> MouseKeysOn key).]
  • the author is an ISO advocate, because of an unrelated "angle mod" (shown in the next symbol chart and other threads there)

User avatar
Laser
emacs -nw

04 Jul 2018, 18:07

Lustique wrote: Well, I really hoped I could achieve this software-wise, especially as Hasu converters aren't exactly cheap… :(
Actually, a PS2->USB converter using Hasu's *firmware* is very very cheap, you only need a Pro Micro, which is a few bucks.

User avatar
TuxKey
LLAP

04 Jul 2018, 18:31

love linux but alas can't help i have never used a "tiling windows manager" my mates keep telling me it's the best ever..
so perhaps one day.. when this mac dies and i need to switch from vmware to a linux distro with good virtualization..

good luck mate.. hope you find a solution.. i do agree with laser if you can find a hardware solution that's better then tinkering with software avoids update problems and multiple systems usage..

Still i understand your need don't forget to backup and document you success (i'm sure you will get there) btw you can always try to see if the guys from "jupiterbroadcasting" know anyone that's a tiling windows manager nut to help out ;-)

User avatar
Lustique

18 Jul 2018, 14:52

I had another go, because I realised that while I have mapped my ‘Scroll Lock’ key to ‘mod3’, I never use it anyways, so I might as well just map ‘Escape’ to ‘mod3’, which is otherwise unused (‘mod3’, that is; and then use ‘xcape’). So I did the following:

Code: Select all

$  cat .Xmodmap 

add Mod3 = Scroll_Lock

Code: Select all

$  xmodmap -pm

xmodmap:  up to 2 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d),  Hyper_L (0xcf)
mod3        Scroll_Lock (0x4e),  Mode_switch (0xcb)
mod4        Super_L (0x85),  Super_L (0xce)
mod5        ISO_Level3_Shift (0x5c)

Code: Select all

$  xmodmap -e "clear mod3"
$  xmodmap -pm
xmodmap:  up to 2 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d),  Hyper_L (0xcf)
mod3      
mod4        Super_L (0x85),  Super_L (0xce)
mod5        ISO_Level3_Shift (0x5c)

Code: Select all

$  xmodmap -e "add mod3 = Escape"
$  xmodmap -pm
xmodmap:  up to 2 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0x32),  Shift_R (0x3e)
lock        Caps_Lock (0x42)
control     Control_L (0x25),  Control_R (0x69)
mod1        Alt_L (0x40),  Meta_L (0xcd)
mod2        Num_Lock (0x4d),  Hyper_L (0xcf)
mod3        Escape (0x9),  y (0x34)
mod4        Super_L (0x85),  Super_L (0xce)
mod5        ISO_Level3_Shift (0x5c)
Does anyone have any idea why this bullshit with the ‘y’ key keeps happening? I thought this somehow had something to do with ‘mod4’ already being used before I tried to map another key to it, but that doesn't seem to be the case…
davkol wrote: It has little to do with Colemak besides being hosted on a Colemak forum by a Colemak advocate.
The Extend mappings are mostly positional so they'll work with any layout – even if some keys like A and ZXCVB might be easier to remember using Colemak or QWERTY.
It isn't restricted to ANSI either:
  • the main modifier is in the Model M's Caps Lock key position
    Instead of an extra hardware key, the Extend mappings can use any key really as that extra "Fn"/Shift-type modifier, but usually it's CapsLock that gets the honor.
  • the second symbolic chart shows an ISO layout
    Image
    Symbolic chart of my Extend mappings. Greens, navigation; blue, mousing; orange, multimedia; gray, system/misc.
    World/ISO board showing Windows mappings with MouseWheel R/L keys. [1st image: US/ANSI board with Linux mappings (missing the <LSGT> MouseKeysOn key).]
  • the author is an ISO advocate, because of an unrelated "angle mod" (shown in the next symbol chart and other threads there)
Yeah, sorry, I didn't realise this at first. The thing is, though, that I, for one, don't want to manually mess with my system files (which is something that I think I'd have to do to use this layout), and, while the extra navigation keys would be nice, ‘neo 3’ already has those (on layer 4), and I don't really need media keys.

Or am I misunderstanding what you mean by ‘having a look at this layout’? Were you suggesting that I have a look at the implementation and then try to hack something together myself?
Laser wrote: […]
Actually, a PS2->USB converter using Hasu's *firmware* is very very cheap, you only need a Pro Micro, which is a few bucks.


Yes, of course, building one yourself would be very cheap, but I have no soldering equipment myself, and the only thing I did solder myself a couple of years ago with my father's old soldering iron was a replacement plug for an audio cable, so I also pretty much have no soldering experience, either…

I plan on getting some soldering equipment in the future, because I want to build my own keyboard (kit) some day, but at the moment this isn't really an option.

User avatar
vvp

19 Jul 2018, 09:56

i3 user here. +1 for tilling window managers.

I would post a bug report to xmodmap maintainers about the "y" key.

There was a time when I used a keyboard without win keys too. I remapped right alt to Win key at first. I remapped left control to Win key later (mostly because some software needs both left and right alt keys but there is hardly any software which makes distinction between left and right control).

At the end, I built a custom keyboard which has many keys for modifiers easily accessible on thumbs. No hassle with modifiers now. I'm satisfied :)

User avatar
Laser
emacs -nw

19 Jul 2018, 12:18

Lustique wrote:
Laser wrote: […]
Actually, a PS2->USB converter using Hasu's *firmware* is very very cheap, you only need a Pro Micro, which is a few bucks.


Yes, of course, building one yourself would be very cheap, but I have no soldering equipment myself, and the only thing I did solder myself a couple of years ago with my father's old soldering iron was a replacement plug for an audio cable, so I also pretty much have no soldering experience, either…

I plan on getting some soldering equipment in the future, because I want to build my own keyboard (kit) some day, but at the moment this isn't really an option.
Or you could ask somebody else to do it for you :)

You would need a Pro Micro and a 4-pin flat plastic connector similar to that which connects the ps2 wires to the pcb. And, optional but recommended, a micro-usb to mini-usb or micro-usb short adapter (stress-relief for the Pro Micro connection). This, assuming the Pro Micro would be placed inside the keyboard, and not used as a generic converter - in that latter case you would need a PS/2 female jack instead.

Post Reply

Return to “Keyboards”