diff options
author | Mattias Andrée <maandree@kth.se> | 2021-06-26 14:28:22 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-06-26 14:28:22 +0200 |
commit | 7a0b602f284da36ba0e51a6a171e221b0cf63fd8 (patch) | |
tree | 688b1068b6394da743b367d65b6451dbaf9f415b /xorg-server/setkeys | |
parent | Add xmonad-autofocus-output (diff) | |
download | dotfiles-7a0b602f284da36ba0e51a6a171e221b0cf63fd8.tar.gz dotfiles-7a0b602f284da36ba0e51a6a171e221b0cf63fd8.tar.bz2 dotfiles-7a0b602f284da36ba0e51a6a171e221b0cf63fd8.tar.xz |
Add setkeys and setres
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'xorg-server/setkeys')
-rwxr-xr-x | xorg-server/setkeys | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/xorg-server/setkeys b/xorg-server/setkeys new file mode 100755 index 0000000..5837607 --- /dev/null +++ b/xorg-server/setkeys @@ -0,0 +1,154 @@ +#!/bin/dash + +load_layout () { + if test -f "${XDG_RUNTIME_DIR}/.setkeys_layout"; then + cat "${XDG_RUNTIME_DIR}/.setkeys_layout" + fi +} + +save_layout () { + printf '%s\n' "$1" > "${XDG_RUNTIME_DIR}/.setkeys_layout" +} + +if test "$1" = "greek"; then + layout=gr +elif test "$1" = "swedish"; then + layout=se +elif test "$1" = "english"; then + layout=en_US +elif test "$1" = "toggle"; then + layout="$(load_layout)" + if test "$layout" = se; then + layout=gr + else + layout=se + fi +elif test $# = 0; then + layout="$(load_layout)" +else + layout="$1" +fi +if test -z "$layout"; then + layout=se +fi +save_layout "$layout" + +setxkbmap \ + -rules evdev \ + -model pc105 \ + -layout "$layout" \ + -variant '' \ + -option '' \ + -option terminate:ctrl_alt_bksp,compose:rwin,keypad:future \ + -types complete \ + -compat complete \ + -synch + +{ + # Assign LeftCtrl to CapsLock + printf '%s\n' 'keycode 66 = Control_L Control_L Control_L Control_L' + + # Assign LeftHyper to LeftCtrl + printf '%s\n' 'keycode 37 = Hyper_L Hyper_L Hyper_L Hyper_L' + + # Assign remove layout switch from LeftShift + printf '%s\n' 'keycode 50 = Shift_L Shift_L Shift_L Shift_L' + + if test -z "${NO_UNICOMP}"; then + # Unicomp's newer versions of New Model M swapped AltGr and RSuper + # making it a torture device for even someone with as big hands as mine + if cat /sys/class/input/*/name | grep Unicomp > /dev/null; then + # Assign Compose to AltGr + printf '%s\n' 'keycode 108 = Multi_key Multi_key Multi_key Multi_key' + + # Assign AltGr to RightSuper + printf '%s\n' 'keycode 134 = ISO_Level3_Shift ISO_Level3_Shift ISO_Level3_Shift ISO_Level3_Shift' + fi + fi + + cat <<EOF +clear Shift +clear Lock +clear Control +clear mod1 +clear Mod2 +clear Mod3 +clear Mod4 +clear Mod5 +add Shift = Shift_L Shift_R +add Control = Control_L Control_R +add Mod1 = Alt_L Meta_L +add Mod2 = Num_Lock +add Mod3 = Hyper_L +add Mod4 = Super_L +add Mod5 = ISO_Level3_Shift +EOF +} | xmodmap - + +if cat /sys/class/input/*/name | grep Unicomp > /dev/null; then + # Turn off numlock LED + input="$(grep Unicomp /sys/class/input/*/name | sed 's|^/sys/class/input/\(.*\)/name:.*$|\1|g' | sed 1q)" + if ! echo 0 | sponge "/sys/class/leds/${input}::numlock/brightness" 2>/dev/null; then + if isfg; then + # TODO do at boot + asroot chown ${USER}:${USER} "/sys/class/leds/${input}::numlock/brightness" + echo 0 | sponge "/sys/class/leds/${input}::numlock/brightness" + fi + fi +fi + +# Esc = 9 +# F1…F10 = 67…76 +# F11…F12 = 95…96 +# § = 49 +# 1…9 = 10…18 +# 0+´ = 19…21 +# Backspace = 22 +# Tab = 23 +# qwertyuiopå¨ = 24…35 +# Enter = 36 +# CapsLock = 66 +# asdfghjklöä = 38…48 +# ' = 51 +# LeftShift = 50 +# < = 94 +# zxcvbnm,.- = 52…61 +# RightShift = 62 +# LeftCtrl = 37 +# LeftSuper = 133 +# Alt = 64 +# Space = 65 +# AltGr = 108 +# RightSuper = 134 +# Menu = 135 +# RightCtrl = 105 +# SysReq = 107 +# ScrlLock = 78 +# Break = 127 +# Insert = 118 +# Home = 110 +# PageUp = 112 +# Delete = 119 +# End = 115 +# PageDown = 117 +# Up = 111 +# Left = 113 +# Down = 116 +# Right = 114 +# NumLock = 77 +# Num/ = 106 +# Num* = 63 +# Num- = 82 +# Num7 = 79 +# Num8 = 80 +# Num9 = 81 +# Num+ = 86 +# Num4 = 83 +# Num5 = 84 +# Num6 = 85 +# Num1 = 87 +# Num2 = 88 +# Num3 = 89 +# NumEnter = 104 +# Num0 = 90 +# Num, = 91 |