voidrice/.local/bin/statusbar/sb-kbselect

18 lines
668 B
Text
Raw Normal View History

2020-06-23 21:15:01 +00:00
#!/bin/sh
2020-06-23 20:28:55 +00:00
# works on any init system
# requirements: dmenu, xorg-setxkbmap
kb="$(setxkbmap -query | grep -oP 'layout:\s*\K\w+')" || exit 1
2020-06-23 20:28:55 +00:00
case $BLOCK_BUTTON in
1) kb_choice="$(awk '/! layout/{flag=1; next} /! variant/{flag=0} flag {print $2, "- " $1}' /usr/share/X11/xkb/rules/base.lst | dmenu -l 15)"
[ -z "$kb_choice" ] && exit 0
2020-06-23 20:28:55 +00:00
kb="$(echo "$kb_choice" | awk '{print $3}')"
setxkbmap "$kb"
pkill -RTMIN+30 "${STATUSBAR:-dwmblocks}";;
3) notify-send "⌨ Keyboard/language module" "$(printf "%s" "\- Current layout: $(setxkbmap -query | grep -oP 'layout:\s*\K\w+')")
2020-06-23 21:15:01 +00:00
- Left click to change keyboard.";;
2020-06-23 20:28:55 +00:00
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
echo "$kb"