I want to use the CLI to switch the “primary” property between my monitors. I have the built-in screen of my laptop and an external screen connected by HDMI.
I found a lot of advice for using xrandr
(on Ubuntu forum mainly, though I’m on Manjaro). However, it doesn’t work for me.
Here’s (what I think is) the relevant part of the output of:
> xrandr
Screen 0: minimum 320 x 200, current 1920 x 2160, maximum 16384 x 16384
eDP-1 connected 1920x1080+0+1080 (normal left inverted right x axis y axis) 344mm x 193mm
1920x1080 144.00*+ 60.02 59.97 59.96 59.93
1680x1050 59.95 59.88
% [...] %
320x175 85.27
HDMI-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 527mm x 296mm
1920x1080 60.00*+ 74.97 50.00 59.94
1600x900 60.00
% [...] %
720x400 70.08
DP-1-0 disconnected (normal left inverted right x axis y axis)
DP-1-1 disconnected (normal left inverted right x axis y axis)
When I do either:
xrandr --output eDP-1 --primary
xrandr --output HDMI-1 --primary
… I get no output, my terminal signals the command has run successfully, but nothing changes (the old primary remains primary).
And when I run:
xrandr --output $(xrandr --listactivemonitors | awk '{print $4}') --primary
… I get the error message:
xrandr: unrecognized option 'eDP-1' % (or 'HDMI-1')
Try 'xrandr --help' for more information.
So what’s going on…?
Thanks!
EDIT: I found a way to do this easily with kscreen-doctor
(see this post on the Manjaro Forum). It’s not only xrandr
so it doesn’t really solve the question in this post but it works well and does the same thing, so I guess I’d as well put it here too.
The command is:
kscreen-doctor output.$(xrandr --listactivemonitors | grep "1: " | awk '{print $4}').primary
Cheers!