Skip to content

Instantly share code, notes, and snippets.

@floitsch
Created September 30, 2026 09:53
Show Gist options
  • Select an option

  • Save floitsch/77cd90b8c46eb9deb2b7b46fba657c30 to your computer and use it in GitHub Desktop.

Select an option

Save floitsch/77cd90b8c46eb9deb2b7b46fba657c30 to your computer and use it in GitHub Desktop.
Switch Samsung monitor input

Scripts and desktop files to switch the input of my Samsung (which automatically switches the USB hub as well). This way I can switch to the other computer by just clicking a button.

[Desktop Entry]
Type=Application
Name=Switch Monitor to HDMI
GenericName=Monitor Input Switcher
Comment=Switch the Samsung monitor to HDMI
Icon=video-display
Exec=/home/floitsch/Desktop/switch-monitor-input.sh hdmi
Terminal=false
StartupNotify=false
Categories=Utility;
Actions=HDMI;DisplayPort;USBC;
[Desktop Action HDMI]
Name=Switch to HDMI
Icon=video-display
Exec=/home/floitsch/Desktop/switch-monitor-input.sh hdmi
[Desktop Action DisplayPort]
Name=Switch to DisplayPort
Icon=video-display
Exec=/home/floitsch/Desktop/switch-monitor-input.sh dp
[Desktop Action USBC]
Name=Switch to USB-C
Icon=video-display
Exec=/home/floitsch/Desktop/switch-monitor-input.sh usb-c
[Desktop Entry]
Type=Application
Name=Switch Monitor to HDMI
GenericName=Monitor Input Switcher
Comment=Switch the Samsung monitor to HDMI
Icon=video-display
Exec=/home/floitsch/Desktop/switch-monitor-input.sh usb-c
Terminal=false
StartupNotify=false
Categories=Utility;
Actions=HDMI;DisplayPort;USBC;
[Desktop Action HDMI]
Name=Switch to HDMI
Icon=video-display
Exec=/home/floitsch/Desktop/switch-monitor-input.sh hdmi
[Desktop Action DisplayPort]
Name=Switch to DisplayPort
Icon=video-display
Exec=/home/floitsch/Desktop/switch-monitor-input.sh dp
[Desktop Action USBC]
Name=Switch to USB-C
Icon=video-display
Exec=/home/floitsch/Desktop/switch-monitor-input.sh usb-c
#!/usr/bin/env bash
set -euo pipefail
input="${1:-hdmi}"
case "${input,,}" in
hdmi)
code=0x11
;;
dp|displayport)
code=0x0F
;;
usb|usb-c|usbc)
code=0x36
;;
*)
echo "Usage: $(basename "$0") [hdmi|dp|usb-c]" >&2
exit 2
;;
esac
ddcutil --display 1 setvcp 60 "$code"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment