#!/bin/bash
{
runtime="${XDG_RUNTIME_DIR}/i3blocks"
[[ ! -d "$runtime" ]] && mkdir -p "$runtime"

[[ ! -f "$runtime/keyboard" ]] && [[ -z "$button" ]] && button=1

#case $button in
#	1) swaymsg input "type:keyboard" xkb_variant bepo_afnor; echo "bépo" > "$runtime/keyboard";;
#	2) swaymsg input "type:keyboard" xkb_variant oss; echo "oss " > "$runtime/keyboard";;
#	3) swaymsg input "type:keyboard" xkb_variant us; echo "qwer" > "$runtime/keyboard";;
#esac
case $button in
	1) setxkbmap fr bepo_afnor; echo "bépo" > "$runtime/keyboard";;
	#1) xmodmap ~/.Xmodmap; echo "bépo" > "$runtime/keyboard";;
	2) setxkbmap fr oss; echo "oss " > "$runtime/keyboard";;
	3) setxkbmap fr us; echo "qwer" > "$runtime/keyboard";;
esac
} &>/dev/null
cat "$runtime/keyboard"