You are not logged in.

#1 2019-02-19 19:46:09

Kalixyz
Member
Registered: 2019-02-16
Posts: 11

Startup with multimonitor

Hi i am a new arch user and i have a issue with setting up my 2 monitors the way i want them at startup.
My main monitor i want to be DVI-D-1-1, and to the left of that i want HDMI-2.

Currently i am using a dmenu script called displayselect, that i got from Luke Smith's dotfiles on github.
The way my setup is now i have to run it every time i reboot or startup my computer.

Lovely script but as you probably can imagine this routine is getting old quite fast.
What do i have to do to make my setup persistently act in the same way as after i run the dmenu script?

For those interested in looking at the script i will paste it here(I take 0 credit for this script since it is not mine!):

#!/bin/sh

# A UI for detecting and selecting all displays.
# Probes xrandr for connected displays and lets user select one to use.
# User may also select "manual selection" which opens arandr.
# I plan on adding a routine from multi-monitor setups later.

twoscreen() { # If multi-monitor is selected and there are two screens.

    mirror=$(printf "no\\nyes" | dmenu -i -p "Mirror displays?")
    # Mirror displays using native resolution of external display and a scaled
    # version for the internal display
    if [ "$mirror" = "yes" ]; then
        external=$(echo "$screens" | dmenu -i -p "Optimize resolution for:")
        internal=$(echo "$screens" | grep -v "$external")

        res_external=$(xrandr --query | sed -n "/^$external/,/\+/p" | \
            tail -n 1 | awk '{print $1}')
        res_internal=$(xrandr --query | sed -n "/^$internal/,/\+/p" | \
            tail -n 1 | awk '{print $1}')

        res_ext_x=$(echo $res_external | sed 's/x.*//')
        res_ext_y=$(echo $res_external | sed 's/.*x//')
        res_int_x=$(echo $res_internal | sed 's/x.*//')
        res_int_y=$(echo $res_internal | sed 's/.*x//')

        scale_x=$(echo "$res_ext_x / $res_int_x" | bc -l)
        scale_y=$(echo "$res_ext_y / $res_int_y" | bc -l)

        xrandr --output "$external" --auto --scale 1.0x1.0 \
            --output "$internal" --auto --same-as "$external" \
            --scale "$scale_x"x"$scale_y"
    else

        primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
        secondary=$(echo "$screens" | grep -v "$primary")
        direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
        xrandr --output "$primary" --auto --scale 1.0x1.0 --output "$secondary" --"$direction"-of "$primary" --auto --scale 1.0x1.0
    fi
    }

morescreen() { # If multi-monitor is selected and there are more than two screens.
	primary=$(echo "$screens" | dmenu -i -p "Select primary display:")
	secondary=$(echo "$screens" | grep -v "$primary" | dmenu -i -p "Select secondary display:")
	direction=$(printf "left\\nright" | dmenu -i -p "What side of $primary should $secondary be on?")
	tertiary=$(echo "$screens" | grep -v "$primary" | grep -v "$secondary" | dmenu -i -p "Select third display:")
	xrandr --output "$primary" --auto --output "$secondary" --"$direction"-of "$primary" --auto --output "$tertiary" --"$(printf "left\\nright" | grep -v "$direction")"-of "$primary" --auto
	}

multimon() { # Multi-monitor handler.
	case "$(echo "$screens" | wc -l)" in
		1) xrandr $(echo "$allposs" | grep -v "$screens" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
		2) twoscreen ;;
		*) morescreen ;;
	esac ;}

# Get all possible displays
allposs=$(xrandr -q | grep "connected")

# Get all connected screens.
screens=$(echo "$allposs" | grep " connected" | awk '{print $1}')

# Get user choice including multi-monitor and manual selection:
chosen=$(printf "%s\\nmulti-monitor\\nmanual selection" "$screens" | dmenu -i -p "Select display arangement:") &&
case "$chosen" in
	"manual selection") arandr ; exit ;;
	"multi-monitor") multimon ;;
	*) xrandr --output "$chosen" --auto --scale 1.0x1.0 $(echo "$allposs" | grep -v "$chosen" | awk '{print "--output", $1, "--off"}' | tr '\n' ' ') ;;
esac

setbg		# Fix background if screen size/arangement has changed.
remaps		# Re-remap keys if keyboard added (for laptop bases)
pgrep -x dunst >/dev/null && killall dunst && setsid dunst & # Restart dunst to ensure proper location on screen

Offline

#2 2019-02-19 19:49:14

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Startup with multimonitor

You put the relevant xrandr line in your .xinitrc. Almost all of that script is bloat as you will already know what your displays are called and their dimensions.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2019-02-19 20:02:56

Kalixyz
Member
Registered: 2019-02-16
Posts: 11

Re: Startup with multimonitor

Ty so much for the quick response!
I put this command in .xinitrc if anyone have the same issue in the future...

xrandr --output DVI-D-1-1 --auto --right-of HDMI-2

Worked like a charm(i see what you mean about bloat now) wink

Offline

#4 2019-02-19 20:05:18

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Startup with multimonitor

echo "$allposs" | grep -v "$screens" | awk '{print "--output", $1, "--off"}' | tr '\n' ' '

Bloatification loves bloat...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

Board footer

Powered by FluxBB