Skip to content

Instantly share code, notes, and snippets.

@foosel
Created January 31, 2021 23:45
Show Gist options
  • Save foosel/774f3d47f80ff4759e3ca133451c3ef0 to your computer and use it in GitHub Desktop.
Save foosel/774f3d47f80ff4759e3ca133451c3ef0 to your computer and use it in GitHub Desktop.
KMonad config to turn a ThinkPad X240 keyboard UHK alike. Combined with .Xmodmap for german umlauts and fixed ins/end shenanigans.
! Fix ThinkPad shenanigans
keycode 118 = End
keycode 115 = Insert
! AltGr is Mode_switch
clear mod5
keycode 108 = Mode_switch
! AltGr shortcuts for umlauts
keycode 39 = s S ssharp
keycode 38 = a A adiaeresis Adiaeresis
keycode 30 = u U udiaeresis Udiaeresis
keycode 32 = o O odiaeresis Odiaeresis
keycode 26 = e E EuroSign EuroSign
keycode 49 = grave asciitilde degree
keycode 57 = n N ntilde Ntilde
#| UHK on an X240
|
| KMonad configuration for a ThinkPad X240 with an ANSI keyboard, using a US
| layout as a base. Roughly emulates an Ultimate Hacking Keyboard's mod layer.
|
| Space is mapped as a tap-space/hold-mod key. Alternatively, Capslock is also
| remapped as mod key. Currently only arrow keys, home, end, del and page up/down
| are mapped on the mod layer.
|
| Template for a new layer:
|
| (deflayer name
|
| _
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
| _ _ _ _ _ _ _ _ _ _ _ _ _ _
| _ _ _ _ _ _ _ _ _ _ _ _ _ _
| _ _ _ _ _ _ _ _ _ _ _ _ _
| _ _ _ _ _ _ _ _ _ _ _ _
| _ _ _ - _ _ _ _ _ _
| _ _ _
| )
|
| Author: @foosel
| based on https://github.com/david-janssen/kmonad/blob/master/keymap/user/slotThe/x220-iso-us-colemak-dh-z.kbd
|
|#
(defcfg
input (device-file "/dev/input/by-path/platform-i8042-serio-0-event-kbd")
output (uinput-sink
"KMonad: X240"
"sleep 0.2s; xset r rate 230 70; sleep 0.2s; setxkbmap -option compose:menu")
cmp-seq compose ;; looks odd, but with compose:menu this HAS to be compose, not menu
fallthrough true ;; we don't want to have to worry about all the Fn stuff
)
(defalias
mod (layer-toggle mod) ;; Switching to the UHK mod layer
)
(defalias
smh (tap-hold 200 spc @mod) ;; Space when tapped, mod toggle when held
tmd @mod
)
(defsrc
end
esc f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 home ins del
grv 1 2 3 4 5 6 7 8 9 0 - = bspc
tab q w e r t y u i o p [ ] \
caps a s d f g h j k l ; ' ret
lsft z x c v b n m , . / rsft
lctl lmet lalt spc ralt prnt rctl pgup up pgdn
left down rght
)
(deflayer qwerty
end
esc f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 home ins del
grv 1 2 3 4 5 6 7 8 9 0 - = bspc
tab q w e r t y u i o p [ ] \
@tmd a s d f g h j k l ; ' ret
lsft z x c v b n m , . / rsft
lctl lmet lalt @smh ralt prnt rctl pgup up pgdn
left down rght
)
(deflayer mod
_
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ pgup home up ins del _ _ _
_ _ _ _ _ _ pgdn left down rght _ _ _
_ _ _ _ _ _ _ _ _ _ _ _
_ _ _ _ _ _ _ _ _ _
_ _ _
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment