Last active
May 27, 2019 07:40
-
-
Save katoozi/782751ccd3017bed6567ede810e32faa to your computer and use it in GitHub Desktop.
show current language layout in i3blocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add this line to i3 config file | |
# change us,ir based on your language layout | |
exec --no-startup-id "setxkbmap -layout us,ir -option 'grp:ctrl_alt_toggle'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[language] | |
interval=persist | |
command=~/.i3/language-layout.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
killall kbdd 2>/dev/null | |
kbdd >/dev/null || exit 1 | |
# Get initial state of layout | |
N=$( dbus-send --print-reply=literal --dest=ru.gentoo.KbddService\ | |
/ru/gentoo/KbddService ru.gentoo.kbdd.getCurrentLayout 2>/dev/null |\ | |
sed -un 's/^.*uint32 //p' ) | |
# In case dbus service wasn't available yet, poll until service is ready | |
while [[ -z "$N" ]]; do | |
sleep .1 | |
N=$( dbus-send --print-reply=literal --dest=ru.gentoo.KbddService\ | |
/ru/gentoo/KbddService ru.gentoo.kbdd.getCurrentLayout 2>/dev/null |\ | |
sed -un 's/^.*uint32 //p' ) | |
done | |
echo $( dbus-send --print-reply=literal --dest=ru.gentoo.KbddService \ | |
/ru/gentoo/KbddService ru.gentoo.kbdd.getLayoutName uint32:$N ) | |
# Parse dbus output | |
dbus-monitor "interface='ru.gentoo.kbdd',member='layoutNameChanged'" |\ | |
sed -un '0~2p' | sed -un 's:.*string "\(.*\)".*:\1:p' | sed -u '/:/d' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment