Skip to content

Instantly share code, notes, and snippets.

@56quarters
Last active September 21, 2020 15:51
Show Gist options
  • Save 56quarters/3f82bc03761670e14d05d12af7175250 to your computer and use it in GitHub Desktop.
Save 56quarters/3f82bc03761670e14d05d12af7175250 to your computer and use it in GitHub Desktop.
# Switch the input of the monitor when we detect the logitech mouse is removed
ACTION=="remove", ENV{ID_MODEL}=="Gaming_Mouse_G402", RUN+="/usr/local/bin/ddc-display.sh 1"
# Switch the input of the monitor when we detect the logitech mouse is removed
ACTION=="remove", ENV{ID_MODEL}=="Gaming_Mouse_G402", RUN+="/usr/local/bin/ddc-display.sh 2"
#!/bin/sh
# Set the input for the monitor using ddcutil. Requires that the user is
# in the i2c group. Input 1 for the gaming pc, 2 for the laptop dock.
main() {
case "$1" in
1 )
# Display port (gaming PC)
INPUT="0x0f"
;;
2 )
# Mini display port (laptop dock)
INPUT="0x10"
;;
* )
echo "Unknown display $1"
return 1
;;
esac
# 60 is the "change input" feature
ddcutil --bus=5 setvcp 60 "$INPUT"
return 0
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment