summaryrefslogtreecommitdiff
path: root/.local/bin/chkb
blob: bc6da23db3e0af590ca78c4ee34e64573651f31e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh

set -e

export OSEL_GUI='wofi -d -r "echo \"%s\" | cut -f2 | xargs echo -n"'

choice="`sed -En 's/\s*name\[Group1\]\s*=\s*"([^"]*)"\s*;\s*/\1/p' \
	~/.xkb/symbols/mango \
	| sort \
	| nl -v0 -nln \
	| osel`"

[ -n "$choice" ] && {
	hyprctl -j devices \
		| jq -r '.keyboards[-1].name' \
		| xargs -I{} hyprctl switchxkblayout {} ${choice%	*}
	notify-send -a "${0##*/}" -u normal 'Keyboard Layout Changed' \
		"The keyboard layout was changed to ‘${choice##*	}’"
}