summaryrefslogtreecommitdiff
path: root/bin/extra/cycleKB
blob: 597f26f7a35214dc19dd7a307e540c303269d3ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/sh

list_layouts()
{
cat <<EOF
us
colemak -option ctrl:swapcaps,altwin:menu_win
EOF
}

current_keymap()
{
    setxkbmap -print | awk -F '+' '/xkb_symbols/ {print $2}'
}

NumLayouts="$(list_layouts | wc -l)"
IndexLayout="$(list_layouts | awk "/^$(current_keymap)/ {print NR}")"
[ "$IndexLayout" -eq "$NumLayouts" ] && IndexLayout=1 || IndexLayout=$((IndexLayout + 1))
Layout="$(list_layouts | sed -n "${IndexLayout}p" )"
setxkbmap $Layout &
herbe "_cycleKB" "*${Layout%% *}"