Skip to content

Instantly share code, notes, and snippets.

@dangle
Last active February 14, 2021 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dangle/9dc63ae2ebb48bbad1631fa6a781b1a5 to your computer and use it in GitHub Desktop.
Save dangle/9dc63ae2ebb48bbad1631fa6a781b1a5 to your computer and use it in GitHub Desktop.
A short script to switch between monitor inputs on evdev input swap
#!/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