4

I have been trying to connect from my laptop to my desktop (2 monitors) and only show one of the monitors to my laptop but 2 monitors are always shown beside each other.

What I have tried:

  • x11vnc -display :0.0 Instead of just 0. Which just shows both monitors
  • x11vnc -display :0.1 Which gives an error XOpenDisplay failed (:0.1)
  • x11vnc -display :1 Which gives the same error as above but :1

I have tried to show the options for display peramiter by doing both

(cd /tmp/.X11-unix && for x in X*; do echo ":${x#X}"; done) Which only gives :0

And

for m in $(xrandr --query | grep " connected" | cut -d" " -f1)
do     
    echo $m
done

Which gives

HDMI-0
DP-0

I have also read x11vnc's wiki and xorg's wiki

Also, I have looked at nvidia settings and it shows only 1 screen under x server information which if confusing as it recognised 2 monitors. (I have looked for answers to this but nothing I have found works). For further info, I am running arch and i3. With my xserver running at login with This

T. Roche
  • 63
  • 1
  • 7

1 Answers1

5

What you have on your desktop is a Xinerama display. You can move your mouse cursor as well as windows from one monitor to the other seamlessly. To X, it's one logical display with one screen. Regardless through how many real outputs it is displayed. That's why :0 and :0.0 are the same and the other display:screen identifiers don't work.

You want the -clip option of x11vnc.

This snippet may help you creating x11vnc exports by monitor automatically:

xrandr --listactivemonitors\
|awk -- 'BEGIN { getline } { gsub(/\/[[:digit:]]+/,"",$3) ; print $3 }'\
|while read GEOMETRY
do
    x11vnc -clip $GEOMETRY &
done
Janka
  • 446
  • 3
  • 5
  • 2
    Not sure about Arch, but on Ubuntu x11vnc's man page suggests: `Use '-clip xinerama0' to clip to the first xinerama sub-screen (if xinerama is active). xinerama1 for the 2nd sub-screen, etc.` . Works here anyway... – Tfb9 Aug 27 '20 at 21:16
  • @Tfb9 this was exactly what I was looking for to share one desktop/screen in a multi-monitor configuration. Thank you! – Richard Sep 24 '21 at 21:25
  • RE: `-clip xinerama0`: https://github.com/LibVNC/x11vnc/blob/3e4dc8ef2985a6e670e1d9649fe55395c2b31039/doc/OPTIONS.md?plain=1#L334-L339 – genpfault Oct 04 '22 at 15:13
  • I might do this instead: `xrandr --listactivemonitors | grep eDP-1-1 | awk -- '{ gsub(/\/[0-9]+/,"",$3) ; print $3 }' | while read GEOMETRY...` Where `eDP-1-1` is the name of a specific monitor. That way, there's only one instance of x11vnc running, and it grabs the correct area regardless of the monitor configuration. – AaronD Apr 14 '23 at 21:29