Files
_dotfiles/.config/i3blocks/xkb_layout/xkb_layout
2024-06-12 13:49:42 +02:00

17 lines
606 B
Bash
Executable File

#!/usr/bin/env sh
# This script is supposed to be used as an i3blocks persistent blocklet.
# It outputs current keyboard layout, then waits for it to change in an infinite loop.
# Requires `xkb-switch` utility. Should work in any *sh.
# Written by skidnik <skidnik@gmail.com>
#
# Defaults:
font=${font:-monospace}
font_weight=${font_weight:-bold}
while :
do
# Output current layout:
xkb-switch -p | awk -v font="$font" -v font_weight="$font_weight" '{print "<span font_family=\""font"\" font_weight=\""font_weight"\">"toupper($0)"</span>"}' || sleep 1
# Wait for layout change:
xkb-switch -w
done