2021-05-30 19:10:28 +00:00
|
|
|
self:
|
|
|
|
with self; ''
|
|
|
|
set -e
|
|
|
|
|
|
|
|
current_layout=$(${sway}/bin/swaymsg -t get_inputs | ${jq}/bin/jq -r '.[] | select(.type == "keyboard") | .xkb_active_layout_index' | head -1)
|
|
|
|
total_layouts=$(${sway}/bin/swaymsg -t get_inputs | ${jq}/bin/jq -r '.[] | select(.type == "keyboard") | .xkb_layout_names | length' | head -1)
|
|
|
|
|
2024-03-26 21:07:02 +00:00
|
|
|
next_layout_index=$(expr $current_layout + 1);
|
2021-05-30 19:10:28 +00:00
|
|
|
|
2024-03-26 21:07:02 +00:00
|
|
|
if [ $next_layout_index -ge $total_layouts ]; then
|
|
|
|
next_layout_index=0;
|
2021-05-30 19:10:28 +00:00
|
|
|
fi
|
|
|
|
|
2024-03-26 21:07:02 +00:00
|
|
|
${sway}/bin/swaymsg input '*' xkb_switch_layout "$next_layout_index"
|
|
|
|
|
|
|
|
echo $next_layout_index
|
|
|
|
next_layout=$(${sway}/bin/swaymsg -t get_inputs | ${jq}/bin/jq -r "[ .[] | select(.type == \"keyboard\") | .xkb_layout_names ][0].[$next_layout_index]")
|
2022-04-30 19:43:56 +00:00
|
|
|
${libnotify}/bin/notify-send "$next_layout"
|
2021-05-30 19:10:28 +00:00
|
|
|
''
|