From 097c42b5a8a40245f7596270fce99aaa0356efd2 Mon Sep 17 00:00:00 2001 From: Ismael Puerto Date: Wed, 12 Aug 2015 14:24:02 +0200 Subject: [PATCH 1/3] Add module for view and change keyboard layout --- i3pystatus/xkblayout.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 i3pystatus/xkblayout.py diff --git a/i3pystatus/xkblayout.py b/i3pystatus/xkblayout.py new file mode 100644 index 0000000..07254cb --- /dev/null +++ b/i3pystatus/xkblayout.py @@ -0,0 +1,35 @@ +from i3pystatus import IntervalModule +import subprocess + +#Example +# status.register("xkblayout", +# layouts=["es", "us"]) + + +class Xkblayout(IntervalModule): + interval = 1 + format = u"\u2328 {name}" + settings = ( + ("layouts", "Layouts list"), + ) + on_leftclick = "change_layout" + + def run(self): + kblayout = subprocess.check_output("setxkbmap -query | awk '/layout/{print $2}'", shell=True).decode('utf-8').strip() + + self.output = { + "full_text": self.format.format(name=kblayout).upper(), + "color": "#ffffff" + } + def change_layout(self): + layouts=self.layouts + kblayout = subprocess.check_output("setxkbmap -query | awk '/layout/{print $2}'", shell=True).decode('utf-8').strip() + if kblayout in layouts: + position = layouts.index(kblayout) + try: + subprocess.check_call(["setxkbmap", layouts[position+1]]) + except IndexError: + subprocess.check_call(["setxkbmap", layouts[0]]) + else: + # Go to first position + subprocess.check_call(["setxkbmap", layouts[0]]) From 793b1be03278071fe2e7d530b5e695917bd4505e Mon Sep 17 00:00:00 2001 From: Ismael Puerto Date: Wed, 12 Aug 2015 16:15:06 +0200 Subject: [PATCH 2/3] fix commit e85425c --- ci-build.sh | 6 +++--- i3pystatus/xkblayout.py | 10 +++------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/ci-build.sh b/ci-build.sh index fa142a3..2e693e6 100755 --- a/ci-build.sh +++ b/ci-build.sh @@ -1,7 +1,7 @@ #!/bin/bash -xe python3 --version -py.test --version +py.test-3.4 --version python3 -mpep8 --version # Target directory for all build files @@ -19,7 +19,7 @@ PYTHONPATH=${BUILD}/test-install python3 setup.py --quiet install --install-lib test -f ${BUILD}/test-install-bin/i3pystatus test -f ${BUILD}/test-install-bin/i3pystatus-setting-util -PYTHONPATH=${BUILD}/test-install py.test --junitxml ${BUILD}/testlog.xml tests +PYTHONPATH=${BUILD}/test-install py.test-3.4 --junitxml ${BUILD}/testlog.xml tests # Check that the docs build w/o warnings (-W flag) -sphinx-build -b html -W docs ${BUILD}/docs/ +sphinx-build-3.4 -b html -W docs ${BUILD}/docs/ diff --git a/i3pystatus/xkblayout.py b/i3pystatus/xkblayout.py index 07254cb..79c7839 100644 --- a/i3pystatus/xkblayout.py +++ b/i3pystatus/xkblayout.py @@ -1,10 +1,6 @@ from i3pystatus import IntervalModule import subprocess -#Example -# status.register("xkblayout", -# layouts=["es", "us"]) - class Xkblayout(IntervalModule): interval = 1 @@ -21,15 +17,15 @@ class Xkblayout(IntervalModule): "full_text": self.format.format(name=kblayout).upper(), "color": "#ffffff" } + def change_layout(self): - layouts=self.layouts + layouts = self.layouts kblayout = subprocess.check_output("setxkbmap -query | awk '/layout/{print $2}'", shell=True).decode('utf-8').strip() if kblayout in layouts: position = layouts.index(kblayout) try: - subprocess.check_call(["setxkbmap", layouts[position+1]]) + subprocess.check_call(["setxkbmap", layouts[position + 1]]) except IndexError: subprocess.check_call(["setxkbmap", layouts[0]]) else: - # Go to first position subprocess.check_call(["setxkbmap", layouts[0]]) From 2a91db88cae5b85b4b4fcfb652f5ee8a19cd0577 Mon Sep 17 00:00:00 2001 From: Ismael Date: Wed, 12 Aug 2015 16:16:57 +0200 Subject: [PATCH 3/3] Update ci-build.sh --- ci-build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci-build.sh b/ci-build.sh index 2e693e6..fa142a3 100755 --- a/ci-build.sh +++ b/ci-build.sh @@ -1,7 +1,7 @@ #!/bin/bash -xe python3 --version -py.test-3.4 --version +py.test --version python3 -mpep8 --version # Target directory for all build files @@ -19,7 +19,7 @@ PYTHONPATH=${BUILD}/test-install python3 setup.py --quiet install --install-lib test -f ${BUILD}/test-install-bin/i3pystatus test -f ${BUILD}/test-install-bin/i3pystatus-setting-util -PYTHONPATH=${BUILD}/test-install py.test-3.4 --junitxml ${BUILD}/testlog.xml tests +PYTHONPATH=${BUILD}/test-install py.test --junitxml ${BUILD}/testlog.xml tests # Check that the docs build w/o warnings (-W flag) -sphinx-build-3.4 -b html -W docs ${BUILD}/docs/ +sphinx-build -b html -W docs ${BUILD}/docs/