#!/bin/bash # Refresh /sys devices xrandr -q &>/dev/null have_dells=0 have_widescreen="" have_projector="" have_tv="" display_count=0 # TODO: List screens if none are known # These modes are all supported by the eDP-1 panel zoom_modes=( 640x360 720x405 864x486 960x540 1024x576 1280x720 1360x768 1368x768 1600x900 1920x1080 2048x1152 2560x1440 ) # These all look decently sharp edp_display_modes=( 1600x900 1920x1080 2048x1152 2880x1620 ) chosen_mode=2 all_screens=( ) default_mode=${edp_display_modes[$chosen_mode]} ## The zoomer will source us, don't do anything if that's the case #if [[ "$(basename $BASH_SOURCE)" != "$(basename $0)" ]]; then # return #fi # There is no parse-edid available for Fedora PARSE_EDID=parse-edid if ! which parse-edid &>/dev/null; then PARSE_EDID=read_edid.py fi function setup_display() { for output in /sys/class/drm/card*-*; do if [ "$(cat $output/status)" == "connected" ]; then card=$(basename $output) card=${card##card?-} edid=$(cat $output/edid | $PARSE_EDID 2>&1 | grep Identifier | cut -d '"' -f2) # 27" Dell monitors if [ "$edid" == "DELL U2715H" ]; then have_dells=1 fi # Coral 2.401 projector if [ "$edid" == "AMX_HDMI1_A2" ]; then have_tv=$card fi # 34" widescreen Dell monitors if [ "$edid" == "DELL U3415W" ]; then have_widescreen=$card fi # Cisco + TV if [ "$edid" == "CS-CODECPLUS" ]; then have_tv="$card" fi # Crestron if [ "$edid" == "Crestron" ]; then have_tv="$card" fi all_screens+=( "$card:$edid" ) (( display_count++ )) fi done if [ "$have_dells" == "1" ]; then xrandr --output DP-1 --auto --output DP-2 --auto --right-of DP-1 --output eDP-1 --off elif [ ! -z "$have_widescreen" ]; then xrandr --output $have_widescreen --mode 3440x1440 --output eDP-1 --off elif [ ! -z "$have_tv" ]; then xrandr --output eDP-1 --mode "$default_mode" --output $have_tv --auto --right-of eDP-1 else xrandr --output eDP-1 --mode "$default_mode" --output DP-1 --off --output DP-2 --off --panning 0x0 fi } function zoom_display() { if [ -z "$1" ]; then xrandr --output eDP-1 --mode $default_mode --panning 0x0 else if [ $1 -gt ${#zoom_modes} ]; then echo "There are only ${#zoom_modes} zoom stops" exit 1 fi mode=${zoom_modes[$1]} fi xrandr --output eDP-1 --mode $mode --panning $default_mode } if [[ "$1" == "zoom" ]]; then zoom_display $2 else setup_display fi