#!/bin/sh set -euo pipefail LAST_LAYOUT="" while sleep 1s; do CURRENT_LAYOUT=$(swaymsg -t get_inputs | jq -r '.[]|.xkb_active_layout_name|select(.)' | head -n1) if test "$LAST_LAYOUT" = "$CURRENT_LAYOUT"; then true elif test "$CURRENT_LAYOUT" = "English (Colemak)"; then echo "Setting layout to colemak" setxkbmap us colemak elif test "$CURRENT_LAYOUT" = "Portuguese (Brazil)"; then echo "Setting layout to br" setxkbmap br fi LAST_LAYOUT="$CURRENT_LAYOUT" done