Last active
July 5, 2023 21:10
-
-
Save SL-RU/8c2659f7d62525ee8ab5dee6f426871f to your computer and use it in GitHub Desktop.
Disable touchpad when mouse inserted. Wayland
This file contains hidden or 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
| import pyudev | |
| import subprocess | |
| context = pyudev.Context() | |
| monitor = pyudev.Monitor.from_netlink(context) | |
| monitor.filter_by(subsystem='usb') | |
| def is_m(): | |
| global context | |
| co = 0 | |
| devices = context.list_devices(subsystem='input', ID_INPUT_MOUSE=True) | |
| for device in devices: | |
| print(device.parent['NAME']) | |
| co += 1 | |
| comm = "gsettings set org.gnome.desktop.peripherals.touchpad" | |
| if(co > 1): | |
| print("disabling touchpad") | |
| comm += " send-events disabled" | |
| else: | |
| print("enabling touchpad") | |
| comm += " send-events enabled" | |
| subprocess.Popen(['bash', '-c', comm]) | |
| is_m() | |
| for device in iter(monitor.poll, None): | |
| print(device.action) | |
| if device.action == 'add': | |
| is_m() | |
| pass | |
| if device.action == 'remove': | |
| is_m() | |
| pass | |
| # do something very interesting here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment