How to force a virtual monitor to be always secondary?
up vote
2
down vote
favorite
Created a virtual display so VNC can work when there is no physical display:
/usr/share/X11/xorg.conf.d/20-intel.conf
:
Section "Device"
Identifier "intelgpu0"
Driver "intel"
Option "VirtualHeads" "2"
EndSection
Startup script:
#!/bin/bash
/usr/bin/xrandr -d :0 --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
/usr/bin/xrandr -d :0 --addmode VIRTUAL1 "1600x900_60.00"
/usr/bin/xrandr -d :0
killall -3 gnome-shell
As in https://askubuntu.com/a/1062890/391744
But when plugging in the real monitors they are appearing as secondaries. They show the uninteresting part with no graphical programs visible and no panels/docks.
How to configure it that any non-virtual monitor would automatically become a primary?
For the moment I've only come up with this addition to the script to poll the connected monitors with xrandr
:
(
while [ 1 ]; do
xrandr_out="$(LANG=C /usr/bin/xrandr -d :0)"
# If VIRTUAL is primary.
if egrep -q '^VIRTUAL[0-9]+[[:space:]]+connected[[:space:]]+primary' < <(printf '%sn' "$xrandr_out"); then
# Find non-virtual that is connected.
non_virt="$(sed -nre 's/^([^[:space:]]+)[[:space:]]+connected.*/1/p' < <(printf '%sn' "$xrandr_out" | grep -v ^VIRTUAL) | head -n1)"
if [ -n "$non_virt" ]; then
xrandr -d :0 --output "$non_virt" --primary --pos 0x0
fi
fi
sleep 10
done
) & disown
command-line multiple-monitors display vnc xrandr
add a comment |
up vote
2
down vote
favorite
Created a virtual display so VNC can work when there is no physical display:
/usr/share/X11/xorg.conf.d/20-intel.conf
:
Section "Device"
Identifier "intelgpu0"
Driver "intel"
Option "VirtualHeads" "2"
EndSection
Startup script:
#!/bin/bash
/usr/bin/xrandr -d :0 --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
/usr/bin/xrandr -d :0 --addmode VIRTUAL1 "1600x900_60.00"
/usr/bin/xrandr -d :0
killall -3 gnome-shell
As in https://askubuntu.com/a/1062890/391744
But when plugging in the real monitors they are appearing as secondaries. They show the uninteresting part with no graphical programs visible and no panels/docks.
How to configure it that any non-virtual monitor would automatically become a primary?
For the moment I've only come up with this addition to the script to poll the connected monitors with xrandr
:
(
while [ 1 ]; do
xrandr_out="$(LANG=C /usr/bin/xrandr -d :0)"
# If VIRTUAL is primary.
if egrep -q '^VIRTUAL[0-9]+[[:space:]]+connected[[:space:]]+primary' < <(printf '%sn' "$xrandr_out"); then
# Find non-virtual that is connected.
non_virt="$(sed -nre 's/^([^[:space:]]+)[[:space:]]+connected.*/1/p' < <(printf '%sn' "$xrandr_out" | grep -v ^VIRTUAL) | head -n1)"
if [ -n "$non_virt" ]; then
xrandr -d :0 --output "$non_virt" --primary --pos 0x0
fi
fi
sleep 10
done
) & disown
command-line multiple-monitors display vnc xrandr
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
Created a virtual display so VNC can work when there is no physical display:
/usr/share/X11/xorg.conf.d/20-intel.conf
:
Section "Device"
Identifier "intelgpu0"
Driver "intel"
Option "VirtualHeads" "2"
EndSection
Startup script:
#!/bin/bash
/usr/bin/xrandr -d :0 --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
/usr/bin/xrandr -d :0 --addmode VIRTUAL1 "1600x900_60.00"
/usr/bin/xrandr -d :0
killall -3 gnome-shell
As in https://askubuntu.com/a/1062890/391744
But when plugging in the real monitors they are appearing as secondaries. They show the uninteresting part with no graphical programs visible and no panels/docks.
How to configure it that any non-virtual monitor would automatically become a primary?
For the moment I've only come up with this addition to the script to poll the connected monitors with xrandr
:
(
while [ 1 ]; do
xrandr_out="$(LANG=C /usr/bin/xrandr -d :0)"
# If VIRTUAL is primary.
if egrep -q '^VIRTUAL[0-9]+[[:space:]]+connected[[:space:]]+primary' < <(printf '%sn' "$xrandr_out"); then
# Find non-virtual that is connected.
non_virt="$(sed -nre 's/^([^[:space:]]+)[[:space:]]+connected.*/1/p' < <(printf '%sn' "$xrandr_out" | grep -v ^VIRTUAL) | head -n1)"
if [ -n "$non_virt" ]; then
xrandr -d :0 --output "$non_virt" --primary --pos 0x0
fi
fi
sleep 10
done
) & disown
command-line multiple-monitors display vnc xrandr
Created a virtual display so VNC can work when there is no physical display:
/usr/share/X11/xorg.conf.d/20-intel.conf
:
Section "Device"
Identifier "intelgpu0"
Driver "intel"
Option "VirtualHeads" "2"
EndSection
Startup script:
#!/bin/bash
/usr/bin/xrandr -d :0 --newmode "1600x900_60.00" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
/usr/bin/xrandr -d :0 --addmode VIRTUAL1 "1600x900_60.00"
/usr/bin/xrandr -d :0
killall -3 gnome-shell
As in https://askubuntu.com/a/1062890/391744
But when plugging in the real monitors they are appearing as secondaries. They show the uninteresting part with no graphical programs visible and no panels/docks.
How to configure it that any non-virtual monitor would automatically become a primary?
For the moment I've only come up with this addition to the script to poll the connected monitors with xrandr
:
(
while [ 1 ]; do
xrandr_out="$(LANG=C /usr/bin/xrandr -d :0)"
# If VIRTUAL is primary.
if egrep -q '^VIRTUAL[0-9]+[[:space:]]+connected[[:space:]]+primary' < <(printf '%sn' "$xrandr_out"); then
# Find non-virtual that is connected.
non_virt="$(sed -nre 's/^([^[:space:]]+)[[:space:]]+connected.*/1/p' < <(printf '%sn' "$xrandr_out" | grep -v ^VIRTUAL) | head -n1)"
if [ -n "$non_virt" ]; then
xrandr -d :0 --output "$non_virt" --primary --pos 0x0
fi
fi
sleep 10
done
) & disown
command-line multiple-monitors display vnc xrandr
command-line multiple-monitors display vnc xrandr
edited Nov 27 at 10:53
pa4080
13.2k52461
13.2k52461
asked Nov 27 at 8:06
Velkan
2,2051825
2,2051825
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1096405%2fhow-to-force-a-virtual-monitor-to-be-always-secondary%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown