35

Is it possible to change the resolution of the viewer specified during starting of the vnc server with the geometry command line argument? I have a vncserver configured for a wide screen monitor but I want to view it on a 1024x768 screen.

studiohack
  • 13,468
  • 19
  • 88
  • 118
Rohit Banga
  • 2,354
  • 10
  • 32
  • 41

9 Answers9

24

This same question was asked a while ago on stack overflow: https://stackoverflow.com/questions/15816/changing-the-resolution-of-a-vnc-session-in-linux

The accepted answer from Nathan Fellman:

Real VNC server 4.4 includes support for Xrandr, which allows resizing the VNC. Start the server with:

vncserver -geometry 1600x1200 -randr 1600x1200,1440x900,1024x768

Then resize with:

xrandr -s 1600x1200
xrandr -s 1440x900  
xrandr -s 1024x768  
fgregg
  • 410
  • 1
  • 3
  • 9
  • 3
    With TigerVNC client you don't have to set any geometries on the server side. My server is run with no `-randr` setting at all and just basic `-geometry 1024x768`. This low resolution is used only when you first connect, but then you can change the resolution just by resizing the client window to anything you want, any crazy, non-standard, ad-hoc resolution you want. My setup: openSuse 15.1, GDM, KDE Plasma, TigerVNC client 1.9.0 (Windows) – Espinosa Sep 22 '19 at 21:55
12

With TigerVNC Windows VNC client (viewer) auto resolution works out of the box. No need to set anything anywhere, on the client or on the server. When you first connect to your server, the resolution is set to whatever is preset on the server side but you can easily change it just by resizing the client window; to any resolution, any crazy, non-standard, ad-hoc resolution you want. The remote desktop resolution, say KDE, follows your client window resolution smoothly.

enter image description here

enter image description here

Check that "Resize remote session to the local window" is set. It should be by default.

Please don't confuse auto resolution change with image stretching, alternatively called auto-scaling. This caling is virtually useless, unless you are visually impaired. It works like zoom or looking glass in popular bitmap editors. It just makes pixels bigger (or smaller) by stretching the output image. It decrease image quality significantly, if you stretch a lot.

What users typically want is real resolution change of the remote session. And that is what I talk about earlier and that is what TigetVNC client is capable, providing server has matching functionality. Auto-resolutioning keeps image sharp at any size. Downside is it also increases network bandwidth.

So far I found that only TigerVNC is capable of auto-resolutioning. I tested TightVNC (open source), RealVNC (free version) and UltraVNC (open source) and had no luck with any of them, they provide useless auto-scaling at the best.

TigerVNC homepage: https://tigervnc.org/
TigerVNC sources: https://github.com/TigerVNC/tigervnc
TigerVNC releases on GitHub: https://github.com/TigerVNC/tigervnc/releases
TigerVNC binaries to download: https://sourceforge.net/projects/tigervnc/files/stable/

If you want only viewer, then download only viewer, like vncviewer64-1.12.0.exe, that is just viewer without bundled VNC server. Beware that with TigerVNC server service starts automatically, silently, in the background, which I strongly detest as a possible security threat.

My server is run with no -randr setting at all and just basic -geometry 1024x768. This low resolution is used only when you first connect, but then you can change the resolution just by resizing the client window. If you are curious, here is my full VNC server command:

/usr/bin/Xvnc -log *:syslog:30,TcpSocket:syslog:-1 -inetd -MaxDisconnectionTime=5 -securitytypes=none -displayfd 10 -geometry 1024x768 -AllowOverride=Desktop,AcceptPointerEvents,SendCutText,AcceptCutText,MaxDisconnectionTime,MaxConnectionTime,MaxIdleTime,QueryConnect,QueryConnectTimeOut,AlwaysShared,NeverShared,DisconnectClients,SecurityTypes,Password,PlainUsers -query localhost -once -desktop New session -extension MIT-SHM

According to openSuse package description, xorg-x11-Xvnc - the openSuse VNC server - is built on TigerVNC code. So in my case TigerVNC client talks to TigerVNC server, so perhaps that is why is is all so seamless :)

My client setup: TigerVNC client 1.9.0 (Windows)
My server setup: openSuse 15.1, xorg-x11-Xvnc 1.9.0, vncmanager 1.0.2, GDM, KDE Plasma.

Weijie Chen
  • 103
  • 4
Espinosa
  • 357
  • 5
  • 12
  • This is the correct answer to use "remote resize". I got remote resizing working from OSX Big Sur (11.1) -> Ubuntu 20.04. I did have to install `tigervnc-viewer` from [brew](https://brew.sh/) but that worked great without issue. – fernferret Jan 27 '21 at 11:37
  • Even TigerVNC (v1.11.90) doesn't do resolution scaling with Window size. My Server and client are both Windows. Even with the "Resize remote session to the local window" set in the client, the resolution as well as desktop size is always fixed. If I change the windows size, black bars get added surrounding the remote server desktop. So, neither it does stretching/resizing, nor does it do resolution scaling with window size. – ontherocks Oct 20 '21 at 04:48
  • Do you remote a session, or a single application? I'm trying the later with tigervnc-server and tigner-vnc from GNU Guix (version 1.12.0), and it doesn't seem to resize automatically. The vncviewer also lack a `Resize remote session to the local window` option. Perhaps it doesn't like my minimal window manager (ratpoison). – user30747 Aug 02 '22 at 17:45
  • OK, I see it only works when using sessions. The best is to use the `vncsession`, but I've had `/libexec/vncserver` work also, although that's not really supported. – user30747 Aug 02 '22 at 17:59
10

The UltraVNC viewer supports auto scaling, so it will resize the viewing window automatically, to display the whole screen of the remote server.

VNC Viewer

Update

Both RealVNC and TightVNC display/desktop scaling.

stukelly
  • 1,167
  • 13
  • 21
  • I am using real vnc 4.1.3. where to find the desktop scaling option? I cannot find it. – Rohit Banga Sep 04 '10 at 12:56
  • It is not included in the RealVNC Free Edition, you need to by the Personal or Enterprise version. See the feature comparison http://www.realvnc.com/products/download.html – stukelly Sep 04 '10 at 16:27
  • I have downloaded the ultra vnc viewer. It works thanks. – Rohit Banga Sep 05 '10 at 05:47
  • 12
    Not scaling, but resize, change controlled pc resolution automatically to match to controller screen. – realtebo Jul 07 '18 at 18:55
  • 9
    Beware: auto-scaling does **not** change remote desktop **resolution**, it just makes pixels bigger (or smaller) by stretching the output image. For most users auto scaling is virtually useless, unless you are visually impaired. It decrease image quality significantly. It works like _zoom_ or _looking glass_ in popular bitmap editors. What users really want is real resolution change of the remote session and so far only TigerVNC is capable to do so, from all of the free viewers. See my answer below. – Espinosa Sep 22 '19 at 23:06
  • Is there a keyboard shortcut to enable/disable scaling (and maybe also force maintaining the pixel ratio while resizing) in any of the vnc viewer apps ? – Shodan Jan 08 '22 at 22:31
4

If you need to change the setting without restarting VNC server, I had good results with:

vncconfig -set RandR="1024x768,1600x900"

and then using xrandr to change resolution as fgregg suggested:

xrandr -s 1024x768
xrandr -s 1600x900
Balau
  • 141
  • 3
3

I received an official reply writing to VNC customer service.

The short version is: no, you cannot change remote resolution to automatically match local vnc controller window / screen resolution.

They told me that is because RDP is a real login session, so the screen behaves as you are a common user in the controlled system.

VNC simply mirrors the screen. And it is not a bad thing because you cannot share RDP session but you can share VNC

I suggested to create a config on vnc server to allow the screen changing because I know that windows API allow third party sw to programmatically set screen resolution.

Then I will wait....

realtebo
  • 538
  • 3
  • 9
  • 24
2

I was surprised to find out that setting the resolution on my Raspberry Pi 4 setup with a RealVNC server and client is as simple doing

xrandr --fb 1024x768

in a terminal window on the remote desktop for the OP usecase of 1024x768.


Even though xrandr with no arguments says

$ xrandr 
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 7680 x 7680
HDMI-1 disconnected primary (normal left inverted right x axis y axis)
HDMI-2 disconnected (normal left inverted right x axis y axis)

so you would think it possible to plop just any arbitrary resolution in the given range, in reality it refused to switch to anything higher than 8K (7680x4320). Anything I tried up to that worked fine.

antichris
  • 1,166
  • 7
  • 14
0

For TightVNC, click on the gear icon (settings) and change your picture quality to "High" and it works nicely.

DomainsFeatured
  • 209
  • 1
  • 3
  • 9
  • Why should picture quality be related to automatically screen resolution changing on the controlled part? – realtebo Jul 15 '18 at 06:46
  • It does not work for me. Just tested. This remote resolution driven size of client windows is supported by some VNC clients, like TigerVNC, but **not** TightVNC or RealVNC (free version). I've just tested it with RealVNC Viewer 6.19.715 and TightVNC Viewer for Windows 2.8.23. – Espinosa Sep 22 '19 at 22:03
0

I know that this is an old question, but as I found it looking for a way to setup a xrandr with some default sizes (-xrandr 2600x1600,1280x800,1820x1000,1920x1080,1600x1200,2400x1500,1500x950 did not work for me). To add another mode and resize the window to the new size, I use the following script: The key commands are:

    declare -a mdline=( $(gtf ${ip[0]} ${ip[1]} 60 | grep Modeline) )
    mdname=$(echo ${mdline[1]} | sed -e 's/"//' -e 's/_.*//')
    xrandr --newmode ${mdname} ${mdline[@]:2}
    xrandr --addmode VNC-0 ${mdname}
    xrandr --output VNC-0  --mode ${mdname}

The full script that I use follows:

#!/bin/bash
#############################################################################
# S C R I P T S / v n c _ a d d _ m o d e
# created Mon Apr  4, 2016 12:48 pm by: 
#  Copyright 2016 by SilverLoonSystems, LLC.
#  All Rights Reserved Worldwide
#
#  Licensed under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in
#  compliance with the License.  You may obtain a copy of
#  the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#############################################################################
#
declare -a ip
verb=0
case $# in
    0) ip=( 2400 1500 );;
    1) ip=( $(echo $1 | sed -e 's/x/ /' ) ) ;;
    2) ip=( $1 $2 );;
    *) ip=( hopeless );;
esac

re='^[0-9]+$'
if (( ${#ip[@]} != 2 )) ; then
    echo -n "failed: "
    verb=1
fi
(( $verb != 0 )) && echo '${#ip[@]}' "= ${#ip[@]}"

if !  [[ ${ip[0]}  =~ $re ]] ; then
    echo -n "failed as a number: "
    verb=1
fi
(( $verb != 0 )) && echo  '${ip[0]} ' is ${ip[0]}

if !  [[ ${ip[1]}  =~ $re ]] ; then
    echo -n "failed as a number: "
    verb=1
fi
(( $verb != 0 )) && echo  '${ip[1]} ' is ${ip[1]}

if (( ${#ip[@]} != 2 )) || ! [[ ${ip[0]}  =~ $re ]] || !  [[ ${ip[0]}  =~ $re ]] ; then
    cat <<EOF
error translating the argument list into a screen mode
expecting 0, 1, or 2 arguments
 if zero, then the default 2400x1500 is used
 if 1, then it should be of the format {width}x{height}
 if 2, then the first arg is the width and the second the height 
instead got '$@'
and translated that to {width} ${ip[0]} and {height} ${ip[1]}
EOF
    exit 1
fi
  
echo "xrandr known modes, numbered for your convenience:"
(xrandr 2> /dev/null) | awk '/^ / {printf "mode %2d %s\n", NR-3, $0}'
nm="${ip[0]}x${ip[1]}"
echo "going to try to setup $nm"
if (xrandr 2> /dev/null | grep $nm &> /dev/null) ; then
    echo "mode $nm is already present"
    xrandr --output VNC-0  --mode ${nm}
else
    #set -x
    #set -v
    declare -a mdline=( $(gtf ${ip[0]} ${ip[1]} 60 | grep Modeline) )
    mdname=$(echo ${mdline[1]} | sed -e 's/"//' -e 's/_.*//')
    xrandr --newmode ${mdname} ${mdline[@]:2}
    xrandr --addmode VNC-0 ${mdname}
    xrandr --output VNC-0  --mode ${mdname}
fi

I hope that this helps someone...

ElderDelp
  • 245
  • 2
  • 6
0

With TightVNC (at least) if the server (windows) changes screen resolution then the client automatically changes to match the new resolution.

Simon Sheehan
  • 9,114
  • 12
  • 52
  • 71
rogerdpack
  • 2,146
  • 7
  • 32
  • 49
  • Is it possible to have the RDP behaviour? When the controller connects to a controlled windows is, the controlled windows os change its resolution. Do not Scale, change resolution, to match controller screen resolution, at least on form ratio, than scale to fit. – realtebo Jul 07 '18 at 18:57
  • That would be interesting now sure if it's possible... – rogerdpack Jul 09 '18 at 14:57