3 ms·
My shell-script solution I've been using for the last year or two: #!/bin/bash src="pc" while true; do lsusb -d 04d9:a0d1 >/dev/null # Keyboard conn
by ranma42 5y ago
My shell-script solution I've been using for the last year or two:
#!/bin/bash
src="pc"
while true; do
lsusb -d 04d9:a0d1 >/dev/null # Keyboard connected?
ret=$?
if [ $ret -eq 0 -a "$src" != "pc" ]; then
src="pc"
ddcutil --noverify setvcp 60 0x0f # Switch monitor input to DP
elif [ $ret -eq 1 -a "$src" = "pc" ]; then
src="laptop"
ddcutil --noverify setvcp 60 0x11 # Switch monitor input to HDMI
fi
sleep 1
done
- ur-whale 5y ago> sleep 1 One second latency ... not ideal. Is there any way to sleepwait on a USB config change instead? [EDIT]: this might help: https://stackoverflow.com/questions/469243/how-can-i-listen-for-usb-device-inserted-events-in-linux-in-python https://stackoverflow.com/questions/469243/how-can-i-listen-...