diff options
-rwxr-xr-x | autodetect.sh | 38 | ||||
-rwxr-xr-x | handlers/acpi_event_handler.sh | 4 | ||||
-rwxr-xr-x | handlers/udev_event_handler.sh | 2 | ||||
-rwxr-xr-x | other_vesrions/autodetect_2_displays.sh | 38 | ||||
-rw-r--r-- | rules/20-display-autoset.rules | 1 | ||||
-rw-r--r-- | rules/INSTALL | 6 | ||||
-rw-r--r-- | rules/display-autoset | 2 |
7 files changed, 91 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 diff --git a/handlers/acpi_event_handler.sh b/handlers/acpi_event_handler.sh new file mode 100755 index 0000000..21ba395 --- /dev/null +++ b/handlers/acpi_event_handler.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +#~/bin/displays/autodetect.sh +su -c "DISPLAY=:0.0 arandr" robin; diff --git a/handlers/udev_event_handler.sh b/handlers/udev_event_handler.sh new file mode 100755 index 0000000..8b7541e --- /dev/null +++ b/handlers/udev_event_handler.sh @@ -0,0 +1,2 @@ +#!/bin/sh +su -c "DISPLAY=:0.0 ~/bin/displays/autodetect.sh" robin; diff --git a/other_vesrions/autodetect_2_displays.sh b/other_vesrions/autodetect_2_displays.sh new file mode 100755 index 0000000..2f5def5 --- /dev/null +++ b/other_vesrions/autodetect_2_displays.sh @@ -0,0 +1,38 @@ +#!/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 + diff --git a/rules/20-display-autoset.rules b/rules/20-display-autoset.rules new file mode 100644 index 0000000..75dbd90 --- /dev/null +++ b/rules/20-display-autoset.rules @@ -0,0 +1 @@ +KERNEL=="card0", PROGRAM="/home/robin/bin/displays/udev_event_handler.sh" diff --git a/rules/INSTALL b/rules/INSTALL new file mode 100644 index 0000000..5b5071f --- /dev/null +++ b/rules/INSTALL @@ -0,0 +1,6 @@ +root@robin-note:~# cat /etc/udev/rules.d/20-display-autoset.rules +KERNEL=="card0", PROGRAM="/home/robin/bin/displays/udev_event_handler.sh" + +root@robin-note:~# cat /etc/acpi/events/display-autoset +event=video/switchmode VMOD 00000080 00000000 +action=/home/robin/bin/displays/acpi_event_handler.sh diff --git a/rules/display-autoset b/rules/display-autoset new file mode 100644 index 0000000..58748eb --- /dev/null +++ b/rules/display-autoset @@ -0,0 +1,2 @@ +event=video/switchmode VMOD 00000080 00000000 +action=/home/robin/bin/displays/acpi_event_handler.sh |