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 | |
| parent | 96d5a24bdf1938ae1afaa587ddd28c395eb753bf (diff) | |
immediately update keyboard layout in polybar
| -rw-r--r-- | .config/polybar/config.ini##template | 2 | ||||
| -rwxr-xr-x | .local/share/bin/kbindicator | 24 | 
2 files changed, 18 insertions, 8 deletions
diff --git a/.config/polybar/config.ini##template b/.config/polybar/config.ini##template index 125c15c..94a3b34 100644 --- a/.config/polybar/config.ini##template +++ b/.config/polybar/config.ini##template @@ -124,7 +124,7 @@ label-font = 2  [module/keyboard]  type = custom/script  exec = ~/.local/share/bin/kbindicator -interval = 3 +tail = true  label-font = 1  {% include "config.{{ yadm.hostname }}.ini" %} 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  |