Skip to content

Instantly share code, notes, and snippets.

/keyboard.py Secret

Created April 21, 2015 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b2367596e6fd35c4e84a to your computer and use it in GitHub Desktop.
Save anonymous/b2367596e6fd35c4e84a to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import time
import os
import subprocess
_XKBS=os.path.expanduser("~/.i3/xkblayout-state")
class Py3status(object):
def EmitMessage(self, i4status_output_json, i3status_config):
response = {
"name" : "keyboard",
"cached_until": time.time()+1,
"full_text":"O",
}
out, err = subprocess.Popen([_XKBS,"print","%s"], stderr=subprocess.DEVNULL, stdout=subprocess.PIPE).communicate()
response["full_text"] = out.decode()
return (0,response)
def on_click(self, i3status_output_json, i3status_config, evt):
subprocess.call([_XKBS,"set","+1"],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment