add script to toggle touchpad in wayland

This commit is contained in:
dalahast 2020-05-26 18:29:25 +02:00
parent 62a95b42c7
commit 2f21c97a42

13
.local/bin/toggle_touchpad.py Executable file

@ -0,0 +1,13 @@
#!/usr/bin/python
import json,sys,subprocess
msg = json.loads(subprocess.run(["swaymsg", "-t", "get_inputs"], stdout=subprocess.PIPE).stdout.decode('utf-8'))
for i in range(len(msg)):
if msg[i]["type"] == "touchpad":
if msg[i]["libinput"]["send_events"] == "disabled":
subprocess.run(["swaymsg", "input", msg[i]["identifier"], "events", "enabled"])
subprocess.run(["notify-send", "-a", "Touchpad", "Touchpad Enabled", "-i", "/usr/share/icons/Papirus-Dark/64x64/devices/input-touchpad.svg", "-t", "1500"])
if msg[i]["libinput"]["send_events"] == "enabled":
subprocess.run(["swaymsg", "input", msg[i]["identifier"], "events", "disabled"])
subprocess.run(["notify-send", "-a", "Touchpad", "Touchpad Disabled", "-i", "/usr/share/icons/Papirus-Dark/64x64/devices/input-touchpad.svg", "-t", "1500"])