mirror of
https://github.com/ericonr/dotfiles.git
synced 2024-04-21 09:12:33 -05:00
26 lines
697 B
Bash
Executable File
26 lines
697 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# prints the current keyboard layout and then any layout changes
|
|
# taken from https://github.com/Alexays/Waybar/pull/85
|
|
|
|
swaymsg --type get_inputs --raw | \
|
|
jq --raw-output \
|
|
'[
|
|
.[] |
|
|
select(.type == "keyboard") |
|
|
.xkb_active_layout_name |
|
|
select(contains("English \\(US\\)") | not)
|
|
] |
|
|
first |
|
|
sub("English \\(US\\)"; "us") | sub("Portuguese \\(Brazil\\)"; "br")
|
|
'
|
|
|
|
swaymsg --type subscribe --monitor --raw '["input"]' | \
|
|
jq --raw-output --unbuffered \
|
|
'
|
|
select(.change == "xkb_layout") |
|
|
.input.xkb_active_layout_name |
|
|
sub("English \\(US\\)"; "us") | sub("Portuguese \\(Brazil\\)"; "br")
|
|
'
|
|
|