Skip to content

Instantly share code, notes, and snippets.

@trauner
Created September 7, 2020 00:42
Show Gist options
  • Save trauner/5ab3d5bb58dcb068e5332720fe7ef739 to your computer and use it in GitHub Desktop.
Save trauner/5ab3d5bb58dcb068e5332720fe7ef739 to your computer and use it in GitHub Desktop.
KVM via USB Switch on Fedora 32
#!/usr/bin/zsh
usb_device="046d:c332"
display_output="HDMI-0"
while true
do
if lsusb | grep $usb_device > /dev/null 2>&1
then
if xrandr --listactivemonitors | grep "Monitors: 0" > /dev/null 2>&1
then
xrandr --output $display_output --auto
fi
else
if xrandr --listactivemonitors | grep "+*"$display_output > /dev/null 2>&1
then
xrandr --output $display_output --off
fi
fi
sleep 1s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment