Skip to content

Instantly share code, notes, and snippets.

@LottieVixen
Last active February 19, 2023 17:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save LottieVixen/166fae536ceb2214f795670c8c4c8ee2 to your computer and use it in GitHub Desktop.
Save LottieVixen/166fae536ceb2214f795670c8c4c8ee2 to your computer and use it in GitHub Desktop.
xrandr enable and disable second screen as vnc display

Use a second laptop or headed computer as another monitor via vnc

Firstly check that xrandr has the modeline you need (resolution of the screen you want to use)

$ xrandr
Screen 0: minimum 320 x 200, current 2732 x 768, maximum 16384 x 16384
eDP connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 309mm x 173mm
   1366x768      60.00*+
   1280x720      59.86  
   1152x768      59.78  
   1024x768      59.92  
   800x600       59.86  
   848x480       59.66  
   720x480       59.71  
   640x480       59.38  
HDMI-0 disconnected 1366x768+0+0 (normal left inverted right x axis y axis) 0mm x 0mm
   1366x768      60.00* 
   1280x720      59.86  
VGA-0 disconnected (normal left inverted right x axis y axis)

as you can see my screen eDP is using 1366x768 already which is the resolution I need, if you dont have the res you need, do this to add it

$gtf 1280 1024 60
...
Modeline "1280x1024_60.00"  108.88  1280 1360 1496 1712  1024 1025 1028 1060  -HSync +Vsync

Now lets add this to xrandr like this

$ xrandr --newmode "1280x1024_60.00"  108.88  1280 1360 1496 1712  1024 1025 1028 1060  -HSync +Vsync

Let's add that mode to the display we want to use

$ xrandr --addmode VGA-0 1280x1024_60.00

Let's enable that display that isn't connected and place it relative to the current screen

Unless you want to be unable to use your screen either make the display right or put the x11vnc command on the same line using the ; line terminator

$ xrandr --output VGA-0 --mode 1280x1024_60.00 --left-of LVDS1

and lets share that screen via vnc!

$ x11vnc -clip 1280x1024+0+0

if you notice holding space, backspace and arrow keys aren't doing their usual behaviour, enter this in a new terminal

$ xset r

to turn off the second display (the vnc screen we made) use this

$ xrandr --output VGA-0 --off

then just connect to the vnc server using a vnc client on your pseudo second screen!

information grabbed from here and archived in this fasion for personal use.

xrandr --output HDMI-0 --off
xrandr --addmode HDMI-0 1366x768 -Hsync +Vsync
xrandr --output HDMI-0 --mode 1366x768 --left-of eDP
x11vnc -clip 1366x798+0+0
#NEEDED: Run in another terminal!
#$ xset r
#this allows for holding space to do multiple spaces, arrow keys, repeated movement of cursor etc. to me this is vital
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment