#!/bin/bash #Set this values on new system! ########################################## LVDS_PATH="/sys/class/drm/card0-eDP-1" #VGA_PATH="/sys/class/drm/card0-VGA-1" HDMI_PATH="/sys/class/drm/card0-HDMI-A-1" LVDS_NAME="LVDS1" VGA_NAME="VGA1" HDMI_NAME="HDMI1" ########################################## LVDS_STATUS=$(cat "$LVDS_PATH/status") VGA_STATUS=$(cat "$VGA_PATH/status") HDMI_STATUS=$(cat "$HDMI_PATH/status") XRANDR_OUT=$(xrandr -q) LVDS_MAX=$(echo "$XRANDR_OUT" | grep -A 1 $LVDS_NAME | tail -n1 | awk '{ print $1 }') HDMI_MAX=$(echo "$XRANDR_OUT" | grep -A 1 $HDMI_NAME | tail -n1 | awk '{ print $1 }') VGA_MAX=$(echo "$XRANDR_OUT" | grep -A 1 $VGA_NAME | tail -n1 | awk '{ print $1 }') function handle_non_exist_mode { xrandr --dpi 96 --output $2 --mode $4 --output $1 --mode $3 --left-of $2 } if [[ ($HDMI_STATUS == "connected") && ($VGA_STATUS == "connected") ]]; then ~/bin/d2ext.sh || ~/bin/dnone.sh ; ~/bin/d2ext.sh || handle_non_exist_mode $VGA_NAME $HDMI_NAME $VGA_MAX $HDMI_MAX elif [[ ($HDMI_STATUS == "connected") && ($VGA_STATUS == "disconnected") ]]; then ~/bin/dboth.sh || ~/bin/dnone.sh ; ~/bin/dboth.sh || handle_non_exist_mode $HDMI_NAME $LVDS_NAME $HDMI_MAX $LVDS_MAX elif [[ ($HDMI_STATUS == "disconnected") && ($VGA_STATUS == "connected") ]]; then ~/bin/dvgaboth.sh || ~/bin/dnone.sh ; ~/bin/dvgaboth.sh || handle_non_exist_mode $VGA_NAME $LVDS_NAME $VGA_MAX $LVDS_MAX else ~/bin/dnote.sh || ~/bin/dnone.sh ; ~/bin/dnote.sh fi