PDA

View Full Version : Keyboard, Xkb: Mapping cmd keys to ctrl, win to ctrl, restore esc and delete +



tsukiyoarts
17th April 2017, 01:46 AM
I will not use fedora for long, but I want to share something. Previously I used xmodmap to modify my keyboard key layout, but well, it does not work anymore on fedora 25 and some newer linux distributions, but xkb evdev direct edit does :)

My current keyboard is bluetooth again and uses cmd key (feature of mini keyboards I think). Usually the win key gets mapped to the two cmd keys, esc does not work and the delete key has other function attached to it.

http://forums.fedoraforum.org/picture.php?albumid=446&pictureid=2384


su
gedit /usr/share/X11/xkb/keycodes/evdev

There are 2 ways of discovering the code of the wrong key, one is using the command xev on terminal, the other is by logical thinking, if the delete key is actually powering the system down, search in evdev the key name which has power on it and switch its keycode with the one which has delete in the key name. Worked for me. I needed xev for the esc key.

My layout is as follows, it seems each kernel update it gets reseted, so keep a copy in your user folder when that happens. I changed the esc key code to 180, switched the key codes of win keys and ctrl keys and the delete key with the power key.


<LCTL> = 133;
<RCTL> = 134;
<LWIN> = 37;
<RWIN> = 105;
<ESC> = 180;
<DELE> = 124;
<POWR> = 119;

You can also change the backspace key second string (named too backspace) in the file at /usr/share/X11/xkb/symbols/pc to delete, and cause it to act as a delete key when shift key is pressed with the backspace key. Like an apple keyboard (which I like by size and style).

Note 1: Do mess around with the xkb pc file, as it resulted in strange bluetooth issues for me. I think bluetooth failed because the keyboard layout code failed due to modifications.

Note 2: I think there must be no duplicate key codes in different key names at evdev.

Note 3: I tried to post the full code but the forum system refused. How am I to make a proper guide that way?

lsatenstein
17th April 2017, 11:41 PM
In a similar way I add to ca, and us layouts, the EuroSign and the yen. (By the way, I use the two characters into passwords, because the two are not on the standard keyboard layouts)

These are the two replacement lines.
before
key <AD03> { [ e, E ] };
after
key <AD03> { [ e, E,EuroSign ] };

before
key <AD06> { [ y, Y ] };
after
key <AD06> { [ y, Y,yen ] };

tsukiyoarts
18th April 2017, 12:34 AM
In a similar way I add to ca, and us layouts, the EuroSign and the yen. (By the way, I use the two characters into passwords, because the two are not on the standard keyboard layouts)

These are the two replacement lines.
before
key <AD03> { [ e, E ] };
after
key <AD03> { [ e, E,EuroSign ] };

before
key <AD06> { [ y, Y ] };
after
key <AD06> { [ y, Y,yen ] };

Good night. That is some pretty clever thinking mister.

In my opinion the downside of using special characters for password is which sometimes you may want to access something from another operational system, where or the character does not exist or is harder to input, and sometimes there is no time or will to also learn how to customize the keyboard on those systems.

At command line interface mode (for emergencies), I think sometimes the keyboard custom layout may not be recognized and you will not be able to easily change that to input the correct root password for example. If one only use such special passwords on their linux computer login and root, and not at sites accessed from other operational systems, then the risk of trouble decreases I think.

In my case using would not work for security as it is what they use in Japan, the € would work though. :)

mtk
21st April 2017, 05:14 PM
i'm using xmodmap on F25 without a problem. to what are you referring when you say it 'does not work'?

lsatenstein
22nd April 2017, 02:55 AM
i'm using xmodmap on F25 without a problem. to what are you referring when you say it 'does not work'?

When you have two or three layouts for your keyboard. For example, I use English, French, and I am wanting to program in APL. xmodmap is based on a specific keyboard layout. for example,
xmodmap over a US layout and then change to de or fr, and the xmodmap effect is all screwed up.

I am exploring setxkbmap to learn more about it.

APL


⊃ ∨ ∧ ⌊ ○ ⊂
╔═════╦═════╦═════╦═════╦═════╦═════╦═════╦═════╦═ ════╦═════╦═════╦═════╦═════╦══════════╗
║ ~ ║ ! ⌶ ║ @ ⍫ ║ # ⍒ ║ $ ⍋ ║ % ⌽ ║ ^ ⍉ ║ & ⊖ ║ * ⍟ ║ ( ⍱ ║ ) ⍲ ║ _ ! ║ + ⌹ ║ ║
║ ` ◊ ║ 1 ║ 2 ║ 3 < ║ 4 ≤ ║ 5 = ║ 6 ≥ ║ 7 > ║ 8 ≠ ║ 9 ∨ ║ 0 ∧ ║ - ║ = ║ BACKSP ║
╠═════╩══╦══╩══╦══╩══╦══╩══╦══╩══╦══╩══╦══╩══╦══╩═ ═╦══╩══╦══╩══╦══╩══╦══╩══╦══╩══╦═══════╣
║ ║ Q ║ W ⍹ ║ E ⋸ ║ R ║ T ⍨ ║ Y ║ U ║ I ⍸ ║ O ⍥ ║ P ⍣ ║ { ⍞ ║ } ⍬ ║ | ⊣ ║
║ TAB ║ q ? ║ w ⍵ ║ e ∈ ║ r ⍴ ║ t ∼ ║ y ↑ ║ u ↓ ║ i ⍳ ║ o ○ ║ p ⋆ ║ [ ← ║ ] → ║ \ ⊢ ║
╠════════╩═╦═══╩═╦═══╩═╦═══╩═╦═══╩═╦═══╩═╦═══╩═╦══ ═╩═╦═══╩═╦═══╩═╦═══╩═╦═══╩═╦═══╩═══════╣
║ (CAPS ║ A ⍶ ║ S ║ D ║ F ║ G ║ H ⍋ ║ J ⍤ ║ K ║ L ⌷ ║ : ≡ ║ " ≢ ║ ║
║ LOCK) ║ a ⍺ ║ s ⌈ ║ d ⌊ ║ f _ ║ g ∇ ║ h ∆ ║ j ∘ ║ k ' ║ l ⎕ ║ ; ⍎ ║ ' ⍕ ║ RETURN ║
╠══════════╩═══╦═╩═══╦═╩═══╦═╩═══╦═╩═══╦═╩═══╦═╩══ ═╦═╩═══╦═╩═══╦═╩═══╦═╩═══╦═╩═══════════╣
║ ║ Z ║ X χ ║ C ║ V ║ B ║ N ║ M ║ < ⍪ ║ > ⍙ ║ ? ⍠ ║ ║
║ SHIFT ║ z ⊂ ║ x ⊃ ║ c ∩ ║ v ∪ ║ b ⊥ ║ n ⊤ ║ m | ║ , ⍝ ║ . ⍀ ║ / ⌿ ║ SHIFT ║
╚══════════════╩═════╩═════╩═════╩═════╩═════╩════ ═╩═════╩═════╩═════╩═════╩═════════════╝

gordon64
22nd April 2017, 04:40 AM
I think setxkb* works only on X11 and not wayland