Skip to content

Instantly share code, notes, and snippets.

@joshskidmore
Created August 27, 2019 09:51
Show Gist options
  • Save joshskidmore/830f486353a62a55bc575110f1f7c984 to your computer and use it in GitHub Desktop.
Save joshskidmore/830f486353a62a55bc575110f1f7c984 to your computer and use it in GitHub Desktop.
keyboard.sh
#!/usr/bin/env bash
export DISPLAY=:0
HARD_RESET=$1
reset_kbd () {
xdotool keyup Shift_L Shift_R Control_L Control_R Meta_L Meta_R Alt_L Alt_R Super_L Super_R Hyper_L Hyper_R ISO_Level2_Latch ISO_Level3_Shift ISO_Level3_Latch ISO_Level3_Lock ISO_Level5_Shift ISO_Level5_Latch ISO_Level5_Lock Caps_Lock 204 205 206 207
setxkbmap -layout us
xmodmap -e 'clear mod2' #numlock
local xcape_cnt=$(pgrep xcape | wc -l)
killall xcape
}
caps_to_ctrl() {
xmodmap -e 'clear lock'
xmodmap -e 'clear control'
xmodmap -e 'keycode 66 = Control_L'
xmodmap -e 'add control = Control_L'
xcape -e 'Control_L=Escape' -t 175 &
}
super_alt_swap() {
xmodmap -e 'keycode 64 = Super_L'
xmodmap -e 'keycode 133 = Alt_L'
xmodmap -e 'remove mod1 = Super_L'
xmodmap -e 'remove mod4 = Alt_L '
xmodmap -e 'add mod4 = Super_L'
xmodmap -e 'add mod1 = Alt_L'
}
bar_to_ctrl() {
xmodmap -e 'keycode 51 = Hyper_L'
xmodmap -e 'remove mod4 = Hyper_L'
xmodmap -e 'add control = Hyper_L'
xmodmap -e 'keycode any = backslash bar'
xcape -e 'Hyper_L=backslash|bar' -t 200 &
}
slash_to_super () {
xmodmap -e 'keycode 61 = Super_R'
xmodmap -e 'keycode any = slash question'
xcape -e 'Super_R=slash|question' -t 200 &
}
alt_to_chat() {
xcape -e "Alt_L=XF86Documents" -t 350 &
}
super_to_f12() {
xcape -e 'Super_L=F12' -t 350 &
}
kb_default() {
reset_kbd
caps_to_ctrl
super_alt_swap
bar_to_ctrl
slash_to_super
alt_to_chat
super_to_f12
}
[[ -n "$HARD_RESET" ]] && \
sleep 5 && kb_default &
kb_default
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment