Last active
February 14, 2021 20:33
-
-
Save dangle/9dc63ae2ebb48bbad1631fa6a781b1a5 to your computer and use it in GitHub Desktop.
A short script to switch between monitor inputs on evdev input swap
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
#!/usr/bin/python3 | |
import platform | |
import subprocess | |
from pynput import keyboard | |
def toggle_input(): | |
if platform.system() == 'Windows': | |
activate_host() | |
else: | |
activate_guest() | |
def activate_host(): | |
subprocess.run(( | |
'C:\\Program Files (x86)\\Dell\\Dell Display Manager\\ddm.exe', | |
'/1:SetActiveInput', | |
'DP1' | |
)) | |
def activate_guest(): | |
subprocess.run(( | |
'sudo', | |
'ddccontrol', | |
'-r', | |
'0x60', | |
'-w', | |
'17', | |
'dev:/dev/i2c-4' | |
)) | |
hotkey = keyboard.HotKey( | |
keyboard.HotKey.parse('<ctrl_l>+<ctrl_r>'), | |
toggle_input | |
) | |
with keyboard.Listener( | |
on_press=hotkey.press, | |
on_release=hotkey.release | |
) as listener: | |
listener.join() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment