Created
June 27, 2021 16:34
-
-
Save mtwebster/fc03a6c40f8b7a463846d503582b9902 to your computer and use it in GitHub Desktop.
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/python3 | |
import gi | |
gi.require_version('Gio', '2.0') | |
from gi.repository import Gio | |
import os | |
TERMINATE_STR = "terminate\tterminate:ctrl_alt_bksp" | |
try: | |
desktop = os.environ["XDG_CURRENT_DESKTOP"] | |
if desktop == "X-Cinnamon": | |
settings = Gio.Settings(schema_id="org.gnome.libgnomekbd.keyboard") | |
elif desktop == "MATE": | |
settings = Gio.Settings(schema_id="org.mate.peripherals-keyboard-xkb.kbd") | |
elif desktop == "XFCE": | |
os.system("setxkbmap -option terminate:ctrl_alt_bksp") | |
exit(0) | |
opts = settings.get_strv("options") | |
if TERMINATE_STR in opts: | |
exit(0) | |
opts.append(TERMINATE_STR) | |
settings.set_strv("options", opts) | |
settings.sync() | |
except Exception as e: | |
print("setting xkbmap for ctrl-alt-backspace failed") | |
exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment