diff options
author | Robin Obůrka <r.oburka@gmail.com> | 2014-08-22 11:53:46 +0200 |
---|---|---|
committer | Robin Obůrka <r.oburka@gmail.com> | 2014-08-22 11:53:46 +0200 |
commit | f0167e83c71879ec2e64c389e59819c9ff8d170a (patch) | |
tree | c75095e6b2e5cf961c61361110c784cc3f7509c6 /autodetect.sh | |
download | display_autoset-f0167e83c71879ec2e64c389e59819c9ff8d170a.tar.xz |
Initial commit
Diffstat (limited to 'autodetect.sh')
-rwxr-xr-x | autodetect.sh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/autodetect.sh b/autodetect.sh new file mode 100755 index 0000000..495f9c3 --- /dev/null +++ b/autodetect.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +#Set this values on new system! +########################################## +eDP1_PATH="/sys/class/drm/card0-eDP-1" +DP1_PATH="/sys/class/drm/card0-DP-1" +HDMI_PATH="/sys/class/drm/card0-HDMI-A-1" +eDP1_NAME="eDP1" +DP1_NAME="DP1" +HDMI_NAME="HDMI1" +########################################## + +eDP1_STATUS=$(cat "$eDP1_PATH/status") +DP1_STATUS=$(cat "$DP1_PATH/status") +HDMI_STATUS=$(cat "$HDMI_PATH/status") + +XRANDR_OUT=$(xrandr -q) +eDP1_MAX=$(echo "$XRANDR_OUT" | grep -A 1 $eDP1_NAME | tail -n1 | awk '{ print $1 }') +HDMI_MAX=$(echo "$XRANDR_OUT" | grep -A 1 $HDMI_NAME | tail -n1 | awk '{ print $1 }') +DP1_MAX=$(echo "$XRANDR_OUT" | grep -A 1 $DP1_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") && ($eDP1_STATUS == "connected") && ($DP1_STATUS == "disconnected") ]]; then + handle_non_exist_mode $HDMI_NAME $eDP1_NAME $HDMI_MAX $eDP1_MAX + +elif [[ ($HDMI_STATUS == "disconnected") && ($eDP1_STATUS == "connected") && ($DP1_STATUS == "connected") ]]; then + handle_non_exist_mode $DP1_NAME $eDP1_NAME $DP1_MAX $eDP1_MAX + +elif [[ ($HDMI_STATUS == "connected") && ($eDP1_STATUS == "connected") && ($DP1_STATUS == "connected") ]]; then + xrandr --dpi 96 --output $eDP1_NAME --mode $eDP1_MAX --output $HDMI_NAME --mode $HDMI_MAX --left-of $eDP1_NAME --output $DP1_NAME --mode $DP1_MAX --left-of $HDMI_NAME + +elif [[ ($HDMI_STATUS == "disconnected") && ($eDP1_STATUS == "connected") && ($DP1_STATUS == "disconnected") ]]; then + ~/bin/dnote.sh + +fi |