aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.config/polybar/config.ini##template2
-rwxr-xr-x.local/share/bin/kbindicator24
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