Skip to content

Instantly share code, notes, and snippets.

@y1n0
Created September 16, 2017 00:01
Show Gist options
  • Select an option

  • Save y1n0/4409fdb8517b9bd4f1d3f8d1cf7d9569 to your computer and use it in GitHub Desktop.

Select an option

Save y1n0/4409fdb8517b9bd4f1d3f8d1cf7d9569 to your computer and use it in GitHub Desktop.
A tweak to show a language indicator in i3wm's i3status
#!/bin/bash
# You'll need to set a keybind to run this script
# It will change the keyboard layout and create a file in `/tmp`
# indicating the current layout lang.
# Use the module `path_exists` of i3status to check
# if the file (named here `currlang_ar`) is created
layout=$(setxkbmap -query | grep layout | cut -d: -f2 | sed -e 's/^[[:space:]]*//')
if [ $layout == 'us' ] ; then
setxkbmap ar
touch /tmp/currlang_ar
else
setxkbmap us
rm -f /tmp/currlang_ar
fi
exit 0
@DmitryMyadzelets
Copy link

I have output us,ru,it for any of the languages set as the current one.

@bos-s-man
Copy link

I have output us,ru,it for any of the languages set as the current one.

I get current lang xkb-switch -p

@DmitryMyadzelets
Copy link

@bos-s-man, Debian 10:

$ setxkbmap -query | grep layout
layout:     us,ru

Copy link

ghost commented Apr 23, 2021

Dmitry the https://github.com/nonpop/xkblayout-state variant working well. xkblayout-state print "%s" will show you current layout

@DmitryMyadzelets
Copy link

DmitryMyadzelets commented Sep 8, 2021

I ended up using this damn simple code: https://github.com/DmitryMyadzelets/xlayout
Though it's not a script. Seems one can't get the desired result with builtin tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment