From d6111c5f6209326cc30a49b4d96278e862262e62 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Wed, 1 Apr 2020 09:32:11 +0200 Subject: connect-screen: Support multiple displays Signed-off-by: Florian Pritz --- connect-screen | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/connect-screen b/connect-screen index cc1545d..58fa6cd 100755 --- a/connect-screen +++ b/connect-screen @@ -2,10 +2,29 @@ xrandr --output VIRTUAL1 --off xrandr --output HDMI2 --off +xrandr --output DP1 --off +xrandr --output DP2 --off xset r rate 250 50 -if xrandr | grep -q '^HDMI2 connected'; then - xrandr --output HDMI2 --right-of eDP1 --auto +has_hdmi2=$(xrandr | grep '^HDMI2 connected') +has_dp1=$(xrandr | grep '^DP1 connected') +has_dp2=$(xrandr | grep '^DP2 connected') + +if [[ $has_hdmi2 && $has_dp1 ]]; then + xrandr --output DP1 --right-of eDP1 --auto + xrandr --output HDMI2 --right-of DP1 --auto +else + if [[ $has_hdmi2 ]]; then + xrandr --output HDMI2 --right-of eDP1 --auto + fi + + if [[ $has_dp1 ]]; then + xrandr --output DP1 --right-of eDP1 --auto + fi + + if [[ $has_dp2 ]]; then + xrandr --output DP2 --right-of eDP1 --auto + fi fi xkbcomp .xkbmap "$DISPLAY" -- cgit v1.2.3-24-g4f1b