Skip to content

Instantly share code, notes, and snippets.

@emiller
Last active December 29, 2015 03:08
Show Gist options
  • Save emiller/7605107 to your computer and use it in GitHub Desktop.
Save emiller/7605107 to your computer and use it in GitHub Desktop.
Ghetto-fabulous script that sets up a 2560x1440 mode for a laptop's HDMI output, even if it doesn't allow it, and allows toggling usage.
#!/bin/bash
#
# twentyfivesixty-over-hdmi -- force an HDMI output to drive 2560x1440
#
# Ghetto-fabulous script that sets up a 2560x1440 mode for an HDMI output
# and allows toggling usage.
#
# I've been using a Dell U2713HM as an external monitor at work with my
# Lenovo Yoga 13, but unfortunately the HDMI port doesn't detect the native
# resolution of the monitor (2560x1440) as a valid output. In fact, all
# external displays I've connected have capped out at 1920x1080 regardless
# of what they actually support. Since the HDMI 1.3+ spec supports 4kx4k,
# I can't think of a reason why this wouldn't work. So, sure enough,
# setting this mode manually and forcing it to run works just fine at half
# the hz.
#
# Usage:
#
# twentyfivesixty-over-hdmi <setup|enable|disable>
#
# @author emiller
# @date 2013-11-22
#
ACTION=${1:-}
OUTPUT_MAIN="LVDS1"
OUTPUT_HDMI="HDMI1"
MODE_NAME="2560x1440_43.00"
MODE_PRESENT=`xrandr -q | grep $MODE_NAME | grep -v grep`
function usage() {
echo "usage: `basename $0` <setup|enable|disable>"
exit 1
}
case $ACTION in
setup)
if test -z "$MODE_PRESENT"; then
echo "creating mode $MODE_NAME for output $OUTPUT_HDMI"
xrandr --newmode "$MODE_NAME" 162.00 2560 2608 2640 2720 1440 1443 1448 1468 +hsync +vsync
xrandr --addmode "$OUTPUT_HDMI" "$MODE_NAME"
else
echo "mode $MODE_NAME for output $OUTPUT_HDMI already exists"
fi
;;
enable)
echo "enabling $OUTPUT_HDMI @ $MODE_NAME (and disabling $OUTPUT_MAIN)"
xrandr --output "$OUTPUT_HDMI" --primary --mode "$MODE_NAME" --output "$OUTPUT_MAIN" --off
;;
disable)
echo "enabling $OUTPUT_MAIN @ auto (and disabling $OUTPUT_HDMI)"
xrandr --output "$OUTPUT_MAIN" --primary --auto --output "$OUTPUT_HDMI" --off
;;
*)
usage
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment