0

I am running i3wm on Ubuntu 22.04 and have a script that I can manually trigger to add my second monitor if it's connected.

if [[ $(xrandr | grep -c "HDMI1 connected") -eq 1 ]]; then
    xrandr --output eDP1 --primary \
           --output HDMI1 --auto --rotate right \
                          --right-of eDP1;
else
    xrandr --output eDP1 --primary;
    xrandr --output HDMI1 --off;
fi

This gives me a second, vertical display to my right which I can use to scroll through long documents or email inboxes while I focus on the main screen in front of me.

My admittedly minor gripe is that the two screens are aligned at the top, meaning if I move my cursor from the top right corner of my main screen, it goes to the top left corner of the second screen. Seems logical enough.

However, the two monitors are aligned at the bottom, and I would like the displays to be aligned that way, too, i.e., if I move from the top right corner of the main screen, it should go to somewhere in the middle of the right screen.

I've tried adding a --pos XxY argument after --right-of eDP1 in the line for the second monitor, but no combination of X or Y values seems to work to shift the second screen to the position I want.

I can drag and drop the screens in gnome-control-center to achieve what I want if I log in on other DMs, but using those X and Y offsets on i3 has never worked.

What am I missing here?

2 Answers 2

1

You can use ARandR, which is a GUI frontend for xrandr. You can visually arrange multiple displays. It works in i3 for me.

1
  • Thanks for the tip, I'll give it a try. I wonder why this would work and the actual xrandr wouldn't, though.
    – icedwater
    Commented Oct 7, 2023 at 13:31
1

Thanks to the tip from C. Aknesil, I tried arandr and indeed it worked. It gave me the hint that I should manually specify coordinates for my main display as well.

I also found out that --right-of causes xrandr to ignore the coordinates and use a default mapping that aligns the tops, so I removed that.

Here's the updated script:

if [[ $(xrandr | grep -c "HDMI1 connected") -eq 1 ]]; then
    xrandr --output eDP1 --primary --pos 0x1152 \
           --output HDMI1 --auto --rotate right \
                          --pos 1366x0;
else
    xrandr --output eDP1 --primary;
    xrandr --output HDMI1 --off;
fi

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .