#!/bin/bash

current_layout=""

while true; do
  layout=$(hyprctl -j devices | jq -r '.keyboards[] | select(.main==true) | .active_keymap')

  [[ "$layout" == *Russian* ]] && layout="RU"
  [[ "$layout" == *English* ]] && layout="EN"

  if [ "$layout" != "$current_layout" ]; then
    echo "$layout"
    current_layout="$layout"
  fi

  sleep 0.1
done
