geekhack

geekhack Projects => Making Stuff Together! => Topic started by: Taurusko on Thu, 06 November 2014, 09:21:45

Title: XKB Layouts / Ideas / Talk
Post by: Taurusko on Thu, 06 November 2014, 09:21:45
X KeyBoard

XKB is a very powerful, but horribly documented tool for managing layouts on Linux. The learning curve is steep and for most occasions xmodmap is sufficient alternative.
Yet still, I got my hands dirty and I can tell you that the moment you understand how it all works, a new world opens up with infinite possibilities.

Some useful docs:
http://www.charvolant.org/~doug/xkb/html/node5.html (http://www.charvolant.org/~doug/xkb/html/node5.html#Sec:Compat)
https://wiki.archlinux.org/index.php/X_KeyBoard_extension (https://wiki.archlinux.org/index.php/X_KeyBoard_extension)

This thread can serve as a showcase for all of your xkb layouts, Q&A and general talk.


I'll start with the layout I'm currently working on.
Suggestions / Improvements / Critics are welcome :)

.xkb file:
https://drive.google.com/file/d/0B1oaGhBuhlq9cDNmWV9ZZnYtZTg/view?usp=sharing (https://drive.google.com/file/d/0B1oaGhBuhlq9cDNmWV9ZZnYtZTg/view?usp=sharing)
Keyboard Layout
http://www.keyboard-layout-editor.com/#/layouts/7bbf08583d9bf26e10602b956692cdf3 (http://www.keyboard-layout-editor.com/#/layouts/7bbf08583d9bf26e10602b956692cdf3)
Title: Re: XKB Layouts / Ideas / Talk
Post by: PieterGen on Wed, 26 November 2014, 08:24:11
Thank you Taurusko. I will definitely ask questions here, as I'm about to implement my own layout.

Let me ask a first question: is it possible in XKB to assign 2 or more characters to 1 key? I mean: in many languages, the Q is always followed by a U. Que, quote, quality, quiche. Is it possible to make the Q always type QU ?

Normally you would do this in a script, such as Autokey. But in xkb itself is more elegant. Can it be done?
Title: Re: XKB Layouts / Ideas / Talk
Post by: kebby on Sun, 14 December 2014, 05:10:54
I've been fiddling with xkb a bit. I use a custom version of the neo2 layout with standard qwerty alphas and a modified layer 4. My current issue is that I'd like to use the modifier (right alt) that activates the 4th layer also as Meta in Emacs. This would let me use the movement keys from that layer and add the Emacs specifics on top of that.

I'm just not very clear on whether there is some fundamental difference between a modifier like this that switches between layers and one that you can normally use for keyboard shortcuts. Do you know if the config I want is even possible with xkb?

edit:
Well I think I actually finally managed to do this. Only remaining thing is that seems my terminal doesn't play nice with it.
Title: Re: XKB Layouts / Ideas / Talk
Post by: Taurusko on Mon, 15 December 2014, 14:07:22
Sorry for my inactivity. Deadlines are happening.
I took a break from XKB. It was acting strange (stuck keys, not registering keypresses, etc.). No, it wasn't keyboards fault. When I switched back to default setup, everything seems fine. I'll look into this on holidays.


Is it possible in XKB to assign 2 or more characters to 1 key?

As far as I know, this isn't possible. XKB only changes the processing of the keys, it can not create new stuff. But I may be wrong.
So far, the only way is scripting (xdotool, autokey, etc.).

I'm just not very clear on whether there is some fundamental difference between a modifier like this that switches between layers and one that you can normally use for keyboard shortcuts. Do you know if the config I want is even possible with xkb?

edit:
Well I think I actually finally managed to do this. Only remaining thing is that seems my terminal doesn't play nice with it.

Could you please share the original setup and the solution? It sounds like an interesting problem, but I am not sure if I understand what are you trying to accomplish ;)
Title: Re: XKB Layouts / Ideas / Talk
Post by: kebby on Tue, 16 December 2014, 07:08:03
I'm just not very clear on whether there is some fundamental difference between a modifier like this that switches between layers and one that you can normally use for keyboard shortcuts. Do you know if the config I want is even possible with xkb?

edit:
Well I think I actually finally managed to do this. Only remaining thing is that seems my terminal doesn't play nice with it.

Could you please share the original setup and the solution? It sounds like an interesting problem, but I am not sure if I understand what are you trying to accomplish ;)

So I just wanted neo2's movement layer to be triggered with the same modifier I use in Emacs so I could memorise the same keys for all programs and have the additional stuff Emacs provides alongside the basics. In the end it was very simple but I think the solution may be fairly shell/Emacs-specific, most other applications aren't looking for what meta etc. are bound to. I feel like I don't really fully understand how XKB works at this point so it was a slow process of trial and error.

I just assigned the (I assume fake) key <HYPR> to the right modifier which allowed Emacs to see it as the hyper key:
Code: [Select]
modifier_map Mod3 { <HYPR> };
 Chose hyper to not affect the shell and mapped it to be meta in Emacs with x-meta-keysym and x-hyper-keysym. The fake keys like <HYPR> may be specific to the neo2 layout shipping with xorg.

Title: Re: XKB Layouts / Ideas / Talk
Post by: drrtyrokka on Tue, 23 December 2014, 03:02:29
Here is an interesting project from Øystein Bech "DreymaR" Gadmar.

I mainly adopted the "Extended" Layout, which gives you extended functionality through replacing capslock with a mod_level_5.
The good thing is, you can add this to your existing layout with an option in dconf-editor.

The layout looks like this in his file:
(http://dl.dropbox.com/u/14504410/Keyboards/dreymar/doc/Cmk-ISO-Extend_90d.png)

I had to adjust it a bit for my needs, because some functions didn't work as expected.
I had to disable the media key functionality on the function row, because I couldn't change to my ttys.
Futhermore, reenabling capslock lays on scroll lock, but I didn't like that. I changed it with dconf-editor to activate when I tap both Shift keys a time.
(See page 4 in the forum post I mentioned above, There I've described my steps to solve these problems).

Have fun!
Title: Re: XKB Layouts / Ideas / Talk
Post by: kebby on Tue, 23 December 2014, 03:47:16
The layout looks like this in his file:
Show Image
(http://dl.dropbox.com/u/14504410/Keyboards/dreymar/doc/Cmk-ISO-Extend_90d.png)


So the mouse keys can just work from the layer without any need to switch to keyboard mousing? If so I may have to incorporate that to my layer.
Title: Re: XKB Layouts / Ideas / Talk
Post by: drrtyrokka on Tue, 23 December 2014, 04:00:04
I don't really use it, but it works, yes. You can activate/deactivate mouse functions with Extend+Z. 
I recognized that this only works in Firefox for me, but I'm on a VM, perhaps this is the issue. Would be nice if you could have a look in the extend xkb file, if there are suggestions to make it better. I can't tell, that I really understand xkb :D