From dd0e5c46d6bb48a86b9f4d8e5d0477d9b695ef0d Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sat, 24 Feb 2024 16:34:24 +0100 Subject: immediately update keyboard layout in polybar --- .local/share/bin/kbindicator | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to '.local/share') diff --git a/.local/share/bin/kbindicator b/.local/share/bin/kbindicator index 819abb2..ca2acfd 100755 --- a/.local/share/bin/kbindicator +++ b/.local/share/bin/kbindicator @@ -1,9 +1,19 @@ #!/bin/sh -CONTROLLER="`qdbus 'org.fcitx.Fcitx5' '/controller' 'org.fcitx.Fcitx.Controller1.CurrentInputMethod'`" +query_kb_layout() { + CONTROLLER="$(qdbus 'org.fcitx.Fcitx5' '/controller' 'org.fcitx.Fcitx.Controller1.CurrentInputMethod')" + case $CONTROLLER in + "keyboard-us") echo "us" ;; + "keyboard-us-intl") echo "us-intl" ;; + "mozc") echo "jp" ;; + *) ;; + esac +} + +query_kb_layout + +dbus-monitor --address "$(fcitx5-remote -a)" "member='SetCurrentIM',destination='org.fcitx.Fcitx5'" |\ + grep --line-buffered 'SetCurrentIM' |\ + while read -r line ; do + query_kb_layout + done -case $CONTROLLER in - "keyboard-us") echo "us" ;; - "keyboard-us-intl") echo "us-intl" ;; - "mozc") echo "jp" ;; -*) ;; -esac -- cgit v1.2.3