16 lines
443 B
Bash
16 lines
443 B
Bash
#!/usr/bin/env bash
|
|||
|
|
print_layout() {
|
||
|
|
swaymsg -t get_inputs | jq -r '
|
||
|
|
[.[] | select(.type=="keyboard" and .xkb_active_layout_name != null)]
|
||
|
|
| first | .xkb_active_layout_name
|
||
|
|
| if test("Russian") then "RU"
|
||
|
|
elif test("English") then "EN"
|
||
|
|
else .[0:2] end'
|
||
|
|
}
|
||
|
|
while true; do
|
||
|
|
print_layout
|
||
|
|
swaymsg -t subscribe -m '["input"]' | while read -r _; do
|
||
|
|
print_layout
|
||
|
|
done
|
||
|
|
sleep 1
|
||
|
|
done
|