infra/pkgs/toggle-kbd-layout.nix
Benjamin Yule Bädorf 56ea689de6
feat: add nix config to this repository
This used to live in the old pub-solar/os repository in the `momo/main`
branch. This commit changes that so this repository has all code from
terraform to nix.
2024-02-25 17:41:25 +01:00

17 lines
552 B
Nix

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)
next_layout=$(expr $current_layout + 1);
if [ $next_layout -ge $total_layouts ]; then
next_layout=0;
fi
${libnotify}/bin/notify-send "$next_layout"
${sway}/bin/swaymsg input '*' xkb_switch_layout "$next_layout"
''