Last active
November 15, 2017 20:46
-
-
Save DougBeney/e8f9e915d72580b0a4583a840502aa59 to your computer and use it in GitHub Desktop.
Python Script to switch CMD and CTRL on command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
import sys | |
import os | |
project_name = "keyboard" | |
def switchLayout(layout): | |
desired_layout_path = "/opt/" + project_name + "/symbols/" + layout | |
desired_layout_config = open(desired_layout_path, "r") | |
layout_config = open("/usr/share/X11/xkb/symbols/pc", "w") | |
layout_config.write(desired_layout_config.read()) | |
os.system("sudo rm /var/lib/xkb/*.xkm") | |
print("Success!") | |
if len(sys.argv) >= 2: | |
layout = sys.argv[1] | |
if layout == "mac": | |
switchLayout(layout) | |
elif layout == "pc": | |
switchLayout(layout) | |
else: | |
print('Unknown layout "' + layout + '"') | |
else: | |
print("Usage: '"+project_name+" [layout_name]'") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment