diff options
author | lonkaars <loek@pipeframe.xyz> | 2024-02-24 16:34:24 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2024-02-24 16:34:24 +0100 |
commit | dd0e5c46d6bb48a86b9f4d8e5d0477d9b695ef0d (patch) | |
tree | 5d5f289f584d14a84a758ad7a7f4668f4ae5b14e /.local/share/bin/kbindicator | |
parent | 96d5a24bdf1938ae1afaa587ddd28c395eb753bf (diff) |
immediately update keyboard layout in polybar
Diffstat (limited to '.local/share/bin/kbindicator')
-rwxr-xr-x | .local/share/bin/kbindicator | 24 |
1 files changed, 17 insertions, 7 deletions
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 |