You are not logged in.
Pages: 1
I'm trying to set up default monitor configurations at start up with a xrandr script.
I want to duplicate any and all monitors that are connected to my laptop via HDMI, USB-C etc. I created a file "~/.xprofile" with the commands
#!/bin/bash
xrandr --output eDP-1 --mode 1920x1080 --rate 40
xrandr --output HDMI-1 --same-as eDP-1
xrandr --output DP-1 --same-as eDP-1
xrandr --output DP-2 --same-as eDP-1
xrandr --output DP-3 --same-as eDP-1
xrandr --output DP-4 --same-as eDP-1These commands work when only the HDMI monitor is plugged in (and there are no other DPs). But when I'm connected to eg. DP-2 and not HDMI, DP-2 is disabled or the display is extended. Is this caused by the order of the commands? Since there are no HDMI monitors plugged in, then "xrandr --output HDMI-1 --same-as eDP-1" has no effect and so the rest of .xprofile is ignored?
How can I fix this?
Offline
Trinity sources ~/.xprofile from
/opt/trinity/bin/starttde, which does not run with "set -e", so all six of
your lines run every time.
The problem is --same-as: it only positions an output, it never switches
one on. Your HDMI was already enabled, so repositioning it gave you a
mirror; the DP output comes up disabled, so repositioning it does nothing.
Add --auto:
xrandr --output DP-2 --auto --same-as eDP-1
Better, don't hardcode the names at all -- behind a USB-C/MST dock the
outputs are often DP-1-1, DP-1-2 ... and never match your list:
#!/bin/sh
PRIMARY=eDP-1
COMMON=1920x1080
xrandr --output "$PRIMARY" --mode "$COMMON" --rate 40 --primary
xrandr --query | awk '/ connected/ {print $1}' | while read -r OUT; do
[ "$OUT" = "$PRIMARY" ] && continue
xrandr --output "$OUT" --mode "$COMMON" --same-as "$PRIMARY" 2>/dev/null \
|| xrandr --output "$OUT" --auto --same-as "$PRIMARY"
done
The explicit --mode matters: --same-as shares only the origin, not the
resolution, so a higher-res external would otherwise leave your panel
showing just a corner of the screen.
One limit you cannot fix this way: ~/.xprofile runs at login only. For
plugging in while already logged in, use autorandr from the Debian
repositories -- "sudo apt install autorandr", arrange the displays, then
"autorandr --save docked".
Offline
Pages: 1