all repos

dotfiles @ 1f5249ea789001925ac90fade0ab98d430f59555

my dotfiles

config/qtile/kblayout.py (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""
For working widget install `xkblayout`
$ yay -S xkblayout
"""
from libqtile.widget import base
from os import popen


KBCMD = """
case "$(xkblayout)" in
  "Eng") echo "us" ;;
  "Ukr") echo "ua" ;;
esac
"""


class KBLayout(base.InLoopPollText):
    """Widget for displaying the current keyboard layout"""
    orientations = base.ORIENTATION_HORIZONTAL

    def __init__(self, **config):
        base.InLoopPollText.__init__(self, **config)

    def poll(self):
        kb = popen(KBCMD).read()          \
                         .rstrip('\n')    \
                         .encode('utf-8') \
                         .decode('utf-8')
        return kb