mirror of
https://codeberg.org/diginaut/dotfiles.git
synced 2026-02-04 08:50:26 +01:00
Toggle tablet mode in KDE Plasma
This commit is contained in:
21
bin/plasma_toggle_tablet_mode
Executable file
21
bin/plasma_toggle_tablet_mode
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import subprocess
|
||||
import gi
|
||||
|
||||
gi.require_version('Gio', '2.0')
|
||||
from gi.repository import Gio, GLib
|
||||
|
||||
KDE_VERSION = 6
|
||||
OBJECT_PATH = '/kwinrc'
|
||||
INTERFACE_NAME = 'org.kde.kconfig.notify'
|
||||
SIGNAL_NAME = 'ConfigChanged'
|
||||
|
||||
current_mode: str = subprocess.check_output([f"kreadconfig{KDE_VERSION}", "--file", "kwinrc", "--group", "Input", "--key", "TabletMode", "--default", "auto"]).decode(encoding='utf-8').strip()
|
||||
if current_mode == "on":
|
||||
subprocess.check_call([f"kwriteconfig{KDE_VERSION}", "--file", "kwinrc", "--group", "Input", "--key", "TabletMode", "off"])
|
||||
else:
|
||||
subprocess.check_call([f"kwriteconfig{KDE_VERSION}", "--file", "kwinrc", "--group", "Input", "--key", "TabletMode", "on"])
|
||||
|
||||
connection = Gio.bus_get_sync(Gio.BusType.SESSION, None)
|
||||
Gio.DBusConnection.emit_signal(connection, None, OBJECT_PATH, INTERFACE_NAME, SIGNAL_NAME, GLib.Variant.new_tuple(GLib.Variant('a{saay}', {'Input': [b'TabletMode']})))
|
||||
Reference in New Issue
Block a user