#!/bin/sh

swaymsg -r -t get_inputs | \
  grep "xkb_active_layout_name" | \
  awk -F '"' '{print $4}' | \
      sed --unbuffered 's/English (US)/πŸ‡ΊπŸ‡Έ EN/g;s/Spanish/πŸ‡²πŸ‡½ ES/g;s/Russian/πŸ‡·πŸ‡Ί RU/g'| head -1

swaymsg \
  --type subscribe \
  --monitor \
  --raw \
  '["input"]' | \
  jq \
    --raw-output \
    --unbuffered \ '
      select(.change == "xkb_layout") |
        .input.xkb_active_layout_name' | \
      sed --unbuffered 's/English (US)/πŸ‡ΊπŸ‡Έ EN/g;s/Spanish/πŸ‡²πŸ‡½ ES/g;s/Russian/πŸ‡·πŸ‡Ί RU/g'