Skip to content

Instantly share code, notes, and snippets.

@strycore
Last active September 17, 2016 19:40
Show Gist options
  • Save strycore/9748bfbdb55bb3ffb704bc74ab60487f to your computer and use it in GitHub Desktop.
Save strycore/9748bfbdb55bb3ffb704bc74ab60487f to your computer and use it in GitHub Desktop.
Test layout switching in python
import os
import time
import subprocess
print("Set layout to 'us'")
setxkbmap_command = ['setxkbmap', '-model', 'pc101', 'us', '-print']
xkbcomp_command = ['xkbcomp', '-', os.environ.get('DISPLAY', ':0')]
xkbcomp = subprocess.Popen(xkbcomp_command, env=os.environ, stdin=subprocess.PIPE).stdin
subprocess.Popen(setxkbmap_command,
env=os.environ,
stdout=xkbcomp,
stdin=subprocess.PIPE).communicate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment