• You are not logged in.

DreymaR's Big Bag of Keyboard Tricks (Linux/XKB files included)!

  • Started by DreymaR
  • 388 Replies:
  • Reputation: 11
  • Registered: 06-Jun-2013
  • Posts: 560

yes i think you're right - at this stage it starts to become 'tinkering' and, by its nature, pretty subjective

Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

I try to live by the rule that whenever I realize that I'm well into Tinkerland I should backtrack one step. That makes sense to me – better not to change something than to tweak it and most likely gain nothing? Even if the psyche sometimes has a hard time accepting that argument.

My experiences also have time and again proven this principle sound. I have been dabbling and tinkering with my keyboard setup for the better part of the last decade, and in my own view have ended up with a mix of conservation and optimisation that suits me very well indeed. I usually end up with precisely that one step back from where my uncurbed enthusiasm took me!

The key to successful further tinkering for me has been to add layers! When the AltGr mappings were played out and kept to a few concepts (dead keys, and symbols/glyphs that may be necessary in general latin script and aren't on dead keys), an Extend key/layer for navigation and editing and multimedia keys. Next (not well implemented unfortunately) another Extend layer for NumPad++. Etcetera.

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 1
  • Registered: 24-Dec-2012
  • Posts: 20

Hi,

I switched computer and in this one your script works very good.
I have one question: how do I enable the Extend layer using capslock?

Thanks

Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

You need two things: To set the Extend layer option, and a Level5 switch. I've separated these, so you could use something else than Caps as your Extend key as long as you can set it as a Level5 shift key. (Your choices without editing XKB are lwin, rwin, ralt and lsgt – and I've added caps.)

Are you on Ubuntu? In the Keyboard Settings GUI there's an Options button with different categories. One lets you set a Level5 key (I've added Caps as an option there) and the mappings themselves are chosen from the "Miscellaneous Compatibility" features (because something vaguely similar was put there already).

If you're using setxkbmap or the config file directly, it's the 'misc:extend' and 'lv5:caps_switch_lock' (or one of the other keys) options:

setxkbmap -option lv5:caps_switch_lock,misc:extend
Last edited by DreymaR (27-Sep-2013 12:34:14)

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 1
  • Registered: 24-Dec-2012
  • Posts: 20

Great, that line using setxkbmap works like a charm! with every layout!

Thanks a lot!

By the way, I use debian. After setting it with the setxkbmap, it appeared in the KDE System config options, too.

Great job.

Last edited by javix (02-Oct-2013 11:55:32)
Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

Glad it worked. I see that I did write this in the original post – but there's a lot there by now so I wouldn't expect anyone to find everything. :)

It should work with every layout – that doesn't use levels 5-8. To my knowledge, only a few ones do including a fairly experimental Canadian/International one. Other options like mouse pad overlays may use the levels too in which case there'll be a conflict, but in general this method is underused and safe to touch. Unfortunately, I still can't make the A/S/T modifiers work. :(

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 0
  • Registered: 03-Jul-2009
  • Posts: 189

If you are experiencing issues with XKB, I recommend using Xmodmap: it works flawlessly. The only issue is that Xmodmap is not available on login screens.

Dvorak typist here.  Please take my comments with a grain of salt.

Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

Can you tell me how to map the lvl5 of the A, S and T keys to Alt, Shift and Ctrl respectively with Xmodmap, then? It should work so that <lvl5_switch>+S+T+<arrowleft> for instance indeed selects the previous word as expected.

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 0
  • Registered: 03-Jul-2009
  • Posts: 189

Wow, that's an intricate case indeed! I didn't know there was a level 5 key code, I thought they stopped at level 4, both in XKB and Xmodmap.

I wonder how can one accomplish what you have proposed with XKB, since I gave up while just trying to rearrange Control, Alt and Windows, a much simpler task.

My rule of thumb is:
- to remap symbol keys, use XKB;
- for anything else, use Xmodmap.

Dvorak typist here.  Please take my comments with a grain of salt.

Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

XKB has 8 shift levels but few layouts use the ones beyond 4; the Canadian International is a notable exception.

Nice rule of thumb. But I'm still not sure you can do what I need with Xmodmap at all...

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 0
  • Registered: 03-Jul-2009
  • Posts: 189
DreymaR said:

Nice rule of thumb. But I'm still not sure you can do what I need with Xmodmap at all...

I forgot to mention that I'm only interested to remapping keys, not to implementing new behaviours. When I want to "translate" key chords, I use xbindkeys to intercept key chords and then send keystrokes by means of xdotool. It may be convoluted, but it works for me. XKB has been a headache.

Dvorak typist here.  Please take my comments with a grain of salt.

Offline
  • 0
  • Reputation: 0
  • Registered: 11-Oct-2013
  • Posts: 79

I apologize for my previous behaviour. It was thoughtless.

Edit: I got it working with setxkbmap.

Also, is the modifier for level 7 called ISO_Level7_Shift? If not, then what is it?

Also, when you tried out xmodmap did you find out if level2 (3rd and 4th characters defined, used with mode_switch) replaced any of your layers? I was thinking that maybe you could actually use both xkb and xmodmap without having to just use xmodmap. If you don't define level 3 (5th and 6th characters defined), then it shouldn't affect your altgr layer. I'm pretty sure that I have used the altgr level defined in the colemak xkb for keys that I have mapped with xmodmap by touching the altgr portion. I'll reboot and test this when I get a chance (currently I have overwritten the altgr layer with a tab layer), but I'm mostly sure that this should be feasible.

I guess that the advantages would be the use of alt and shift on the caps layer.. you could also use caps+ s (shift in the layer) to get a new layer (4th key defined in xmodmap) if you wanted. Media keys would still work I think. I'm not sure about mouse movement though (is that possible in xkb?). I'm trying to weigh the pros and cons of an extend layer in xkb v in xmodmap.

The other cool thing would be that if the mode_switch layers don't affect any xkb layers, you would have 2 extra layers. If they do affect some level from 5-8 xkb, then it could just serve as a replacement.

Last edited by angelic_sedition (22-Nov-2013 18:11:14)
Offline
  • 0
  • Reputation: 1
  • Registered: 24-Dec-2012
  • Posts: 20

Hi,

I have one issue with the extended lv5 mappings (which I love).

When I activate the setting I loose my function keys (they do not work at all).
If I deactivate lv5 extend mappings I get my function keys back.
This happens with every layout.

Whilst debugging this with showkey -a this is what I get with no lv5 mappings for pressing F1, F2, F3, F4:

^[OP     27 0033 0x1b
         79 0117 0x4f
         80 0120 0x50
^[OQ     27 0033 0x1b
         79 0117 0x4f
         81 0121 0x51
^[OR     27 0033 0x1b
         79 0117 0x4f
         82 0122 0x52
^[OS     27 0033 0x1b
         79 0117 0x4f
         83 0123 0x53

If I activate them this is what I get for the same keys:

^@        0 0000 0x00
^@        0 0000 0x00
^@        0 0000 0x00
^@        0 0000 0x00

Do you know what could be happening and how can I get the function keys to work with the extended lv5 mappings?

Thanks a lot, regards.

I have debian 7, KDE.

Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

@Javix: If the function keys are giving you trouble (I think mine work fine?!), find the X11/xkb/symbols/extend file and comment out all entries for <FK##>. The Extend mappings for function keys are multimedia functions, that usually don't work out of the box for Debian/Ubuntu anyway. If you try to remap manually using the GUI settings on Ubuntu you'll even run into a bug that maps to Lvl5_switch (the Caps key) instead of the resultant key.

Note that the number keys with Extend turn into function keys, for easy access. Doesn't work quite as well as on windows/pkl where Caps+A+4 produces Alt-F4, since the A/S/T modifiers aren't working under xkb (yet).

@angelic_sedition: Hey, no problem.

- I haven't touched lvl9 at all. It's supposed to be there even under Windows, but not implemented anywhere I know of. Lvl7 however is just lvl5+lvl3, i.e., the combination of lvl5 and AltGr (usually)! It has no separate switch although you could make one.

- When I tried XModmap it wiped my AltGr layer even with those levels unmapped. I too thought of using both (XModmap only for A/S/T) but I haven't gotten further with it. And yes, it'd be fun if those extra layers turned out to be available – but I fear that XModmap will not be with us forever so I try not to base myself too heavily on it.

Last edited by DreymaR (15-Jan-2014 09:58:39)

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 1
  • Registered: 24-Dec-2012
  • Posts: 20

Hi DreymaR,

Thanks for answering.
To make this more misterious, I have another laptop with kubuntu 13.10 (instead of debian 7) and the extend mappings work fine, there is no problem with the function keys there.
On the other side, I cannot make my spanish colemak variations work on the ubuntu one (editing es in the symbols folder and all the xml and lst files in rules folder).
I'll continue experimenting and let you know if I finally manage to get it working consistently in both distributions.
Thank you!

Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

Update: Ghen's Rulemak for Cyrillic script has been added as 'Russian (Colemak, phonetic Rulemak)'. Yay!

I've been trying several things for the Extend mapping modifiers (actions, replace key, Overlay1...), but they still aren't working. Frustrating, to say the least.

Last edited by DreymaR (12-Jan-2014 22:44:55)

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 0
  • Registered: 17-Jan-2014
  • Posts: 2

Hi DreymaR,

Having been a colemak user for a few years, I recently found your modified layout(s). I especially like the wide/angle mod.

Have you considered providing your BBoKT as a separate package, instead of as a patch which modifies system files? That way it could be installed alongside the standard xkb files without messing with them.

Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

I'm not sure what you mean by a separate package, as I have no experience making those. Sounds nice – do you know how to do it?

In order to work though, I think it has to modify at least some system files? Well, now that I think about it the only real reason to modify the system files is to see my changes in the option menus (which is all done in the rules component). It might be a lot better to make additional files alongside the originals, and just patch the rules components if you want the menus to show my stuff. Good thinking! :)

On a side note, it seems that my Colemak[eD] has re-entered a more dynamic phase of development! I've managed to get the Extend layer to work much better for Linux after two years of failed attempts (yay!), and I've decided to split out the files so that as few system files as possible have to be patched, like you suggested.

Also, I've come to the conclusion that the Greek letters αβγδε aren't used much so they should give way at least to ÷ו that I actually use quite often – especially the bullet. It's more of a toss-up for µ and π. I originally put almost all the Greek on unshifted AltGr positions for consistency but I guess that's a minor boon and it's broken by αδ being on the same key anyway. In sum, I'll keep π on unshifted AltGr and move βγεµ to shifted positions unless someone has a convincing argument to the opposite effect. (No? Didn't think so. Who cares, right?) ;)

Last edited by DreymaR (20-Jan-2014 10:40:35)

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 0
  • Registered: 03-Jul-2009
  • Posts: 189
DreymaR said:

I'm not sure what you mean by a separate package, as I have no experience making those. Sounds nice – do you know how to do it?

In order to work though, I think it has to modify at least some system files? Well, now that I think about it the only real reason to modify the system files is to see my changes in the option menus (which is all done in the rules component). It might be a lot better to make additional files alongside the originals, and just patch the rules components if you want the menus to show my stuff. Good thinking! :)

You could contact the maintainers and ask them.  Provisions could exist already to add a layout file and generate again the rules components.

Dvorak typist here.  Please take my comments with a grain of salt.

Offline
  • 0
  • Reputation: 0
  • Registered: 17-Jan-2014
  • Posts: 2

I have no idea how to make packages for Ubuntu, but for Arch Linux it is super easy. However, what I failed to communicate clearly in my previous post was that I was hoping that you could provide your layouts as a set of files seperate from the ones provided by xkb. This way Colemak[eD] can be installed alongside the files already present in /usr/share/X11/xkb. From your edit it seems that this is what you're going to do going forward, which is great!

Now for something relating directly to the layout. There is this silly Menu key, positioned between AltGr and the right Control key. Normally this key functions as a right mouse button click, which I find rather useless. Moreover, with a non-wide layout, this key is pretty hard to reach. However, now that my fingers are shifted one key to the right, the Menu key is in the position where AltGr used to be. (I began noting this when I transitioned to the wide layout; I kept hitting the Menu key instead of AltGr :p)

This key could be put to better use. I propose to turn it into a modifier key akin to AltGr, and put common accented characters there. For instance, for Portuguese it would be very nice to not have to use dead keys to input letters such as ã, ê, í and so on.

Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

I use the Menu key as Compose (it's a standard xkb option). On my Extend mappings I have a mapping providing the Menu key press so I won't miss it anyway.

I worked on making separate eD_<something> files instead of the patched <something> xkb files for quite a while before realizing that it is a bad idea! You see, in the rules component there are keyboard models, layouts, variants and options and these are keyed to what files you find them in (e.g., the 'pt' layouts are in the 'pt' file for all variants of Portuguese). Creating new files would mean that you'd have to create a set of artificial models ('eD_pc' instead of just 'pc' models), layouts ('eD_pt' would be a shadow Portuguese) and options. That's going to confuse XKB and the system in a bad way.

+ An upside to the suggestion would be that my files would exist pretty much independently of xkb-data version
+ Also, most of them would just plop down peacefully next to their system counterparts as you suggest
– However, it'd make the rules files unnecessarily complex due to "double bookkeeping"
– Also, I'm pretty sure some functionality would behave erratically with it in some programs
– Also, it'll be harder to merge my changes into xkb at a later point (yes, I'm hoping that can happen!)

In sum, instead of avoiding having to "mess with system files" the idea of separate files leads to a much worse mess! :(

In my Locale Colemak post you'll see that for Portuguese (Unified Symbols) I made a lv1 acute deadkey on LBr, and tilde on RBr. These accents are so important in Portuguese that they should be easily reached.

   Cmk-X-eD-br-usym+pt-awide-sl_crop.png
   Portuguese (Brazil and Portugal) 'Unified Symbols' Colemak[eD]

Last edited by DreymaR (20-Jan-2014 21:50:54)

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360
WONDERFUL NEWS MY FRIENDS! WOO HOO!

I just made the Extend modifiers (A/S/T) work as they should with XKB so they're as useful as they are under Windows/PKL. That's *great* news to me I have to say! I've been working on this problem on and off for two full years, and it's been a lot of head scratching and failed attempts I can tell you.

As you can see, I'm quite stoked. This is an integral part of the goodness of the Extend mappings. There are a few quirks left: Most notably the Undo key still doesn't work, sadly. If you press Caps+S+N (for Shift+Left) you'll select the previous character as expected, and Caps+T+N (Ctrl+Left) jumps back a word as expected – but Caps+S+T+N doesn't register the Left press as I think that's too many keys for the X server! What works though is to press Caps+S+T, let go of the S only and then hit the arrow keys to start move-selecting around.

For the technically inclined: What finally worked for me was to use SetMods() actions for the modifier keys themselves, and RedirectKey() actions for the arrows and other keys that need to be modified by them. As I found out early on, mapping to the key symbolic names alone did nada. Intuitive, huh? ;) I got in contact with Sergej Udaltsov himself, the maintainer of xkb-data. Talking with him about the Extend problems enabled me to see the solution. Thanks, Сергей!

Just in: WTFLOL – I managed to get the Undo key (and Redo on Caps+S+Z) to work as well as Alt-F4! Man, I'm on a roll.
But I have to tell you, that was the ugliest line of code I've seen in xkb so far.
Shortly after, the F keys and wheel scrolling were also brought to heel. Wow.

Last edited by DreymaR (01-Feb-2014 02:05:42)

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 0
  • Registered: 02-Jan-2014
  • Posts: 11

Hi dreymar,

I've asked few question in windows(where I think I undestand it) but I (sadly) need to do some interrogation here also.

I've written my own (naive) keyboard layout adding just keyboard cursor navigation, so I have very little knowledge of xkb. The problem is, that instructions are written rather for people, who do not actually need them. If you want, I'm willing to write step-by-step walkthrough how to install it and set it up, once I understand it, to help new comers. Because, and let be honest now, general user(for example a translator) have absolutely no chance of installing / configuring it. I would like to (selfishly) install it for myself (namely extend layer) and I'd be glad to help others to profit from your great work. Example of generally problematic formulation: "The Extend option is found under Options -> Miscellaneous Compatibility Options" --> there's no such thing in keyboard settings (at least in xfce) and if you succeed googling that you can set it up using "gnome-tweak-tool", the app window is so ridiculously small (and resize forbidden, of course), that you cannot read content of comboboxes. And moreover, it does not probably work this way.

Few questions about things I was unable to set up:
- installation is OK for me.
- enabling extend layer: I added czech colemak layout. There's "compose key position" combo in keyboard setting window, in which there is "capslock" option, but I believe that this is not the right place to set it up. I tried to do it in gnome-tweak-tool and set capslock as lvl5chooser, but even after that extended layout still did not work. Could you elaborate some more how to enable your mods?

Last edited by alfonz19 (26-Jan-2014 21:43:14)
Offline
  • 0
  • Reputation: 214
  • From: Viken, Norway
  • Registered: 13-Dec-2006
  • Posts: 5,360

Well Alfonz, thanks for chiming in! Looking at the topic post I realize that it's confusing and arcane. Linux often is, unfortunately. I want to improve on that, and thank you for your feedback.

One problem is that there are many Linux distros and several graphical environments to choose from. When I said "Ubuntu" I made a mistake because I meant "default Ubuntu" – which again has moved from the Gnome environment to its own Unity environment. Already, confusion reigns.

Also, the Big Bag topic is so ... well ... big, that you probably can't read it all without getting a headache. Not sure what to do about that, except to try and make it clearer in places.

If I remember correctly, in XUbuntu there was still the Options... panel under keyboard settings that you could use to set the Misc:Extend and Level5:Caps_switch_lock options needed for a working Extend layer. Furthermore, in XFCE I think you can still set your keyboard model in the GUI (to use Angle and/or Wide mods)? In Gnome you can't do that anymore and have to edit the files and/or use the setxkbmap command.

I recommend just editing the /etc/default/keyboard file, that's what I do most of the time. If you want to see something happen right away, there's the setxkbmap command. These are described at the end of the topic post.

I have added some clarifications to the main topic. Hope we can make this understandable! :)

Last edited by DreymaR (26-Jan-2014 23:39:17)

*** Learn Colemak in 2–5 steps with Tarmak! ***
*** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

Offline
  • 0
  • Reputation: 0
  • Registered: 02-Jan-2014
  • Posts: 11

well if I'm looking correctly I cannot see options neither in xubuntu 12.04 nor in 13.10.

But command:
sudo setxkbmap -model pc105 -layout no,us -variant cmk_ed_us,euro -option lv5:caps_switch_lock,misc:extend
works. I've MAYBE noticed that if 'no' layout is not first, then extend layer did not work, just like you mentioned some problem when colemak is not first. But after few test I was unable to reproduce it. So maybe the order is not important (related to extend layer to be enabled).

Question: options in -option applies to all layouts, right?

Next. I tried to retype command mentioned above into /etc/default/keyboard like this:

XKBMODEL="pc105"
XKBLAYOUT="no,us"
XKBVARIANT="cmk_ed_us,euro"
XKBOPTIONS="lv5:caps_switch_lock,misc:extend"

then rebooted, and was unable to log in. Immediately after log-in I was back in login screen. I've found nothing in logs (faillog, Xorg.*, syslog, dmesg). I can't figure out what's wrong.

However, if colemak layout has to be first(due to alt-problems you mentioned), then I probably do not want to set it in /etc/default/keyboard anyway, since not everyone can type using this layout. So the command used above is probably better solution. So executing it after successful login is probably fine. Or is there a better way?

I assume that various layout switching applets use this command and there cannot be any conflict. Yes and last thing --> those applets let you define shortcut for changing layout and whether layout is managed globally or per app. This probably has to be specified in options also, right? If it does, can you share how?

thanks.

Offline
  • 0