<p>I use VNC to connect to a Linux workstation at work.  At work I have a 20" monitor that runs at 1600x1200, while at home I use my laptop with its resolution of 1440x900.
If I set the vncserver to run at 1440x900 I miss out on a lot of space on my monitor, whereas if I set it to run at 1600x1200 it doesn't fit on the laptop's screen, and I have to scroll it all the time.</p>

<p>Is there any good way to resize a VNC session on the fly?</p>

<p>My VNC server is RealVNC E4.x (I don't remember the exact version) running on SuSE64.</p>

[{'answer_id': 15824, 'author': 'BlaM', 'author_id': 999, 'author_profile': 'https://Stackoverflow.com/users/999', 'pm_score': 0, 'selected': False, 'text': '<p>As far as I know there\'s no way to change the client\'s resolution just using VNC, as it is just a "monitor mirroring" application.</p>\n\n<p><a href="http://www.tightvnc.com/" rel="nofollow noreferrer">TightVNC</a> however (which is a VNC client and server application) can resize the screen on the client side, i.e. making everything a little smaller (similar to image resizing techniques in graphics programs). That should work if you don\'t use too small font sizes. VNC should theoretically be compatible between different VNC applications.</p>\n'}, {'answer_id': 15865, 'author': 'BlaM', 'author_id': 999, 'author_profile': 'https://Stackoverflow.com/users/999', 'pm_score': -1, 'selected': False, 'text': '<p>I think that depends on your window manager.</p>\n\n<p>I\'m a windows user, so this might be a wrong guess, but: Isn\'t there something called <a href="http://de.wikipedia.org/wiki/X-Server" rel="nofollow noreferrer">X-Server</a> running on linux machines - at least on ones that might be interesting targets for VNC - that you can connect to with "X-Clients"?</p>\n\n<p>VNC just takes everything that\'s on the screen and "tunnels it through your network". If I\'m not totally wrong then the "X" protocol should give you the chance to use your client\'s desktop resolution. </p>\n\n<p>Give <a href="http://de.wikipedia.org/wiki/X-Server" rel="nofollow noreferrer">X-Server</a> on Wikipedia a try, that might give you a rough overview.</p>\n'}, {'answer_id': 15926, 'author': 'Pat', 'author_id': 238, 'author_profile': 'https://Stackoverflow.com/users/238', 'pm_score': 5, 'selected': False, 'text': '<p>I think your best best is to run the VNC server with a different geometry on a different port. I would try based on the <a href="http://www.realvnc.com/products/free/4.1/man/vncserver.html" rel="noreferrer">man page</a></p>\n\n<blockquote>\n<pre><code>$vncserver :0 -geometry 1600x1200\n$vncserver :1 -geometry 1440x900\n</code></pre>\n</blockquote>\n\n<p>Then you can connect from work to one port and from home to another.</p>\n\n<p>Edit: Then use xmove to move windows between the two x-servers.</p>\n'}, {'answer_id': 15952, 'author': 'Blorgbeard', 'author_id': 369, 'author_profile': 'https://Stackoverflow.com/users/369', 'pm_score': 1, 'selected': False, 'text': "<p>I'm not sure about linux, but under windows, tightvnc will detect and adapt to resolution changes on the server. </p>\n\n<p>So you should be able to VNC into the workstation, do the equivalent of right-click on desktop, properties, set resolution to whatever, and have your client vnc window resize itself accordingly.</p>\n"}, {'answer_id': 16126, 'author': 'Pat', 'author_id': 238, 'author_profile': 'https://Stackoverflow.com/users/238', 'pm_score': 1, 'selected': False, 'text': '<blockquote>\n  <p>On the other hand, if there\'s a way to\n  move an existing window from one\n  X-server to another, that might solve\n  the problem.</p>\n</blockquote>\n\n<p>I think you can use <a href="http://ubuntuforums.org/showthread.php?t=202589" rel="nofollow noreferrer">xmove</a> to move windows between two separate x-servers. So if it works, this should at least give you a way to do what you want albeit not as easily as changing the resolution.</p>\n'}, {'answer_id': 1083668, 'author': 'Nathan Fellman', 'author_id': 1084, 'author_profile': 'https://Stackoverflow.com/users/1084', 'pm_score': 8, 'selected': True, 'text': '<p>Real VNC server 4.4 includes support for Xrandr, which allows resizing the VNC.  Start the server with:</p>\n\n<pre><code>vncserver -geometry 1600x1200 -randr 1600x1200,1440x900,1024x768\n</code></pre>\n\n<p>Then resize with:</p>\n\n<pre><code>xrandr -s 1600x1200\nxrandr -s 1440x900\nxrandr -s 1024x768\n</code></pre>\n'}, {'answer_id': 3839759, 'author': 'Tijs', 'author_id': 463917, 'author_profile': 'https://Stackoverflow.com/users/463917', 'pm_score': 6, 'selected': False, 'text': "<p>Found out that the vnc4server (4.1.1) shipped with Ubuntu (10.04) is patched to also support changing the resolution on the fly via xrandr. Unfortunately the feature was hard to find because it is undocumented. So here it is...</p>\n\n<p>Start the server with multiple 'geometry' instances, like:</p>\n\n<pre><code>vnc4server -geometry 1280x1024 -geometry 800x600\n</code></pre>\n\n<p>From a terminal in a vncviewer (with: 'allow dymanic desktop resizing' enabled) use xrandr to view the available modes:</p>\n\n<pre><code>xrandr\n</code></pre>\n\n<p>to change the resulution, for example use:</p>\n\n<pre><code>xrandr -s 800x600\n</code></pre>\n\n<p>Thats it.</p>\n"}, {'answer_id': 6560690, 'author': 'nhed', 'author_id': 652904, 'author_profile': 'https://Stackoverflow.com/users/652904', 'pm_score': 3, 'selected': False, 'text': '<p>Adding to Nathan\'s (accepted) answer:</p>\n\n<p>I wanted to cycle through the list of resolutions but didnt see anything for it:</p>\n\n<pre><code>function vncNextRes()\n{\n   xrandr -s $(($(xrandr | grep \'^*\'|sed \'s@^\\*\\([0-9]*\\).*$@\\1@\')+1)) &gt; /dev/null 2&gt;&amp;1 || \\\n   xrandr -s 0\n}\n</code></pre>\n\n<p>It gets the current index, steps to the next one and cycles back to 0 on error (i.e. end)</p>\n\n<h2><br></h2>\n\n<p><strong>EDIT</strong></p>\n\n<p>Modified to match a later version of xrandr ("*" is on end of line and no leading resolution identifier).</p>\n\n<pre><code>function vncNextRes()\n{\n   xrandr -s $(($(xrandr 2&gt;/dev/null | grep -n \'\\* *$\'| sed \'s@:.*@@\')-2))  || \\\n   xrandr -s 0\n}\n</code></pre>\n'}, {'answer_id': 8388065, 'author': 'Peter', 'author_id': 391313, 'author_profile': 'https://Stackoverflow.com/users/391313', 'pm_score': 5, 'selected': False, 'text': '<p>I\'m running <a href="http://sourceforge.net/apps/mediawiki/tigervnc/index.php?title=Welcome_to_TigerVNC" rel="noreferrer">TigerVNC</a> on my Linux server, which has basic <strong>randr</strong> support. \nI just start vncserver without any -randr or multiple -geometry options.</p>\n\n<p>When I run xrandr in a terminal, it displays all the available screen resolutions:</p>\n\n<pre><code>bash&gt; xrandr\n SZ:    Pixels          Physical       Refresh\n 0   1920 x 1200   ( 271mm x 203mm )   60\n 1   1920 x 1080   ( 271mm x 203mm )   60\n 2   1600 x 1200   ( 271mm x 203mm )   60\n 3   1680 x 1050   ( 271mm x 203mm )   60\n 4   1400 x 1050   ( 271mm x 203mm )   60\n 5   1360 x 768    ( 271mm x 203mm )   60\n 6   1280 x 1024   ( 271mm x 203mm )   60\n 7   1280 x 960    ( 271mm x 203mm )   60\n 8   1280 x 800    ( 271mm x 203mm )   60\n 9   1280 x 720    ( 271mm x 203mm )   60\n*10  1024 x 768    ( 271mm x 203mm )  *60\n 11   800 x 600    ( 271mm x 203mm )   60\n 12   640 x 480    ( 271mm x 203mm )   60\nCurrent rotation - normal\nCurrent reflection - none\nRotations possible - normal\nReflections possible - none\n</code></pre>\n\n<p>I can then easily switch to another resolution (f.e. switch to 1360x768):</p>\n\n<pre><code>bash&gt; xrandr -s 5\n</code></pre>\n\n<p>I\'m using TightVnc viewer as the client and it automatically adapts to the new resolution.</p>\n'}, {'answer_id': 11648533, 'author': 'inukaze', 'author_id': 983309, 'author_profile': 'https://Stackoverflow.com/users/983309', 'pm_score': 0, 'selected': False, 'text': '<p>I have a simple idea, something like this:</p>\n\n<pre><code>#!/bin/sh\n\necho `xrandr --current | grep current | awk \'{print $8}\'` &gt;&gt; RES1\necho `xrandr --current | grep current | awk \'{print $10}\'` &gt;&gt; RES2\ncat RES2 | sed -i \'s/,//g\' RES2\n\nP1RES=$(cat RES1)\nP2RES=$(cat RES2)\nrm RES1 RES2\necho "$P1RES"\'x\'"$P2RES" &gt;&gt; RES\nRES=$(cat RES)\n\n# Play The Game\n\n# Finish The Game with Lower Resolution\n\nxrandr -s $RES\n</code></pre>\n\n<p>Well, I need a better solution for all display devices under Linux and Similars S.O</p>\n'}, {'answer_id': 23974330, 'author': 'Hammad Khan', 'author_id': 777982, 'author_profile': 'https://Stackoverflow.com/users/777982', 'pm_score': 5, 'selected': False, 'text': '<p>Interestingly no one answered this. In TigerVNC, when you are logged into the session. Go to <code>System &gt; Preference &gt; Display</code> from the top menu bar ( I was using Cent OS as my remote Server). Click on the resolution drop down, there are various settings available including 1080p. Select the one that you like. It will change on the fly.</p>\n\n<p><img src="https://i.stack.imgur.com/UUAgd.png" alt="enter image description here"></p>\n\n<p><strong>Make sure you Apply the new setting when a dialog is prompted. Otherwise it will revert back to the previous setting just like in Windows</strong></p>\n'}, {'answer_id': 28777978, 'author': 'Kashyap', 'author_id': 496289, 'author_profile': 'https://Stackoverflow.com/users/496289', 'pm_score': 2, 'selected': False, 'text': "<p>Perhaps the most ignorant answer I've posted but here goes: Use TigerVNC client/viewer and check <code>'Resize remote session to local window'</code> under Screen tab of options.</p>\n\n<p>I don't know what the $%#@ TigerVNC client tells remote vncserver or xrandr or Xvnc or gnome or ... but it resizes when I change the TigerVNC Client window.</p>\n\n<p>My setup:</p>\n\n<ul>\n<li>Tiger VNC Server running on CentOS 6. Hosting GNOME desktop. (Works with RHEL 6.6 too)</li>\n<li>Windows some version with Tiger VNC Client.</li>\n</ul>\n\n<p>With this the resolution changes to fit the size of the client window no matter what it is, and it's not <code>zooming</code>, it's actual resolution change (I can see the new resolution in xrandr output).</p>\n\n<p>I tried all I could to add a new resolution to the xrandr, but to no avail, always end up with <code>'xrandr: Failed to get size of gamma for output default'</code> error.</p>\n\n<p>Versions with which it works for me right now (although I've not had issues with ANY versions in the past, I just install the latest using <code>yum install gnome-* tigervnc-server</code> and works fine):</p>\n\n<pre><code>OS: RHEL 6.6 (Santiago)\nVNC Server:\nName        : tigervnc-server\nArch        : x86_64\nVersion     : 1.1.0\nRelease     : 16.el6\n\n# May be this is relevant..\n$ xrandr --version\nxrandr program version       1.4.0\nServer reports RandR version 1.4\n$ \n\n# I start the server using vncserver -geometry 800x600\n# Xvnc is started by vncserver with following args:\n/usr/bin/Xvnc :1 -desktop plabb13.sgdcelab.sabre.com:1 (sg219898) -auth /login/sg219898/.Xauthority \n-geometry 800x600 -rfbwait 30000 -rfbauth /login/sg219898/.vnc/passwd -rfbport 5901 -fp catalogue:/e\ntc/X11/fontpath.d -pn\n\n\n# I'm running GNOME (installed using sudo yum install gnome-*)\nName        : gnome-desktop\nArch        : x86_64\nVersion     : 2.28.2\nRelease     : 11.el6\n\nName        : gnome-session\nArch        : x86_64\nVersion     : 2.28.0\nRelease     : 22.el6\n\nConnect using Tiger 32-bit VNC Client v1.3.1 on Windows 7.\n</code></pre>\n"}, {'answer_id': 38630417, 'author': 'omiday', 'author_id': 6648502, 'author_profile': 'https://Stackoverflow.com/users/6648502', 'pm_score': 5, 'selected': False, 'text': '<p>As this question comes up first on Google I thought I\'d share a solution using TigerVNC which is the default these days.</p>\n\n<p><code>xrandr</code> allows selecting the display modes (a.k.a resolutions) however\ndue to modelines being <a href="https://github.com/TigerVNC/tigervnc/blob/master/unix/xserver/hw/vnc/xvnc.c" rel="noreferrer">hard\ncoded</a>\nany additional modeline such as "2560x1600" or "1600x900" would need to\nbe <a href="https://marc.info/?l=tigervnc-users&amp;m=130721748515934&amp;w=2" rel="noreferrer">added into the\ncode</a>. I\nthink the developers who wrote the code are much smarter and the hard\ncoded list is just a sample of values. It leads to the conclusion that\nthere must be a way to add custom modelines and <code>man xrandr</code> confirms\nit.</p>\n\n<p>With that background if the goal is to share a VNC session between two\ncomputers with the above resolutions and assuming that the VNC server is\nthe computer with the resolution of "1600x900":</p>\n\n<ol>\n<li><p>Start a VNC session with a geometry matching the physical display:</p>\n\n<pre><code>$ vncserver -geometry 1600x900 :1\n</code></pre></li>\n<li><p>On the "2560x1600" computer start the VNC viewer (I prefer\nRemmina) and connect to the remote VNC\nsession:</p>\n\n<pre><code>host:5901\n</code></pre></li>\n<li><p>Once inside the VNC session start up a terminal window.</p></li>\n<li><p>Confirm that the new geometry is available in the VNC session:</p>\n\n<pre><code>$ xrandr\nScreen 0: minimum 32 x 32, current 1600 x 900, maximum 32768 x 32768\nVNC-0 connected 1600x900+0+0 0mm x 0mm\n   1600x900      60.00 +\n   1920x1200     60.00  \n   1920x1080     60.00  \n   1600x1200     60.00  \n   1680x1050     60.00  \n   1400x1050     60.00  \n   1360x768      60.00  \n   1280x1024     60.00  \n   1280x960      60.00  \n   1280x800      60.00  \n   1280x720      60.00  \n   1024x768      60.00  \n   800x600       60.00  \n   640x480       60.00  \n</code></pre>\n\n<p>and you\'ll notice the screen being quite small.</p></li>\n<li><p>List the modeline (see xrandr article in ArchLinux wiki) for\nthe "2560x1600" resolution:</p>\n\n<pre><code>$ cvt 2560 1600\n# 2560x1600 59.99 Hz (CVT 4.10MA) hsync: 99.46 kHz; pclk: 348.50 MHz\nModeline "2560x1600_60.00"  348.50  2560 2760 3032 3504  1600 1603 1609 1658 -hsync +vsync\n</code></pre>\n\n<p>or if the monitor is old get the GTF timings:</p>\n\n<pre><code>$ gtf 2560 1600 60\n# 2560x1600 @ 60.00 Hz (GTF) hsync: 99.36 kHz; pclk: 348.16 MHz\nModeline "2560x1600_60.00"  348.16  2560 2752 3032 3504  1600 1601 1604 1656 -HSync +Vsync\n</code></pre></li>\n<li><p>Add the new modeline to the current VNC session:</p>\n\n<pre><code>$ xrandr --newmode "2560x1600_60.00"  348.16  2560 2752 3032 3504  1600 1601 1604 1656 -HSync +Vsync\n</code></pre></li>\n<li><p>In the above <code>xrandr</code> output look for the display name on the second\nline:</p>\n\n<pre><code>VNC-0 connected 1600x900+0+0 0mm x 0mm\n</code></pre></li>\n<li><p>Bind the new modeline to the current VNC virtual monitor:</p>\n\n<pre><code>$ xrandr --addmode VNC-0 "2560x1600_60.00"\n</code></pre></li>\n<li><p>Use it:</p>\n\n<pre><code>$ xrandr -s "2560x1600_60.00"\n</code></pre></li>\n</ol>\n'}, {'answer_id': 39777101, 'author': 'Nicholas Sushkin', 'author_id': 789544, 'author_profile': 'https://Stackoverflow.com/users/789544', 'pm_score': 2, 'selected': False, 'text': "<p>Solution by @omiday worked for me in Xvnc TigerVNC 1.1.0, so I condensed it into a single bash function <strong>vncsize x y</strong>. Use it like this: <strong>vncsize 1400 1000</strong>. It works for any VNC output name, &quot;default&quot; or &quot;VNC-0&quot;.</p>\n<pre><code>function vncsize {\n    local x=$1 y=$2\n    local mode\n    if mode=$(cvt &quot;$x&quot; &quot;$y&quot; 2&gt;/dev/null)\n    then\n        if [[ $mode =~ &quot;Modeline (.*)$&quot; ]]\n        then\n            local newMode=${BASH_REMATCH[1]//\\&quot;/}\n            local modeName=${newMode%% *}\n            local newSize=( ${modeName//[\\&quot;x_]/ } )\n            local screen=$(xrandr -q|grep connected|cut -d' ' -f1)\n            xrandr --newmode $newMode\n            xrandr --addmode &quot;$screen&quot; &quot;$modeName&quot;\n            xrandr --size &quot;${newSize[0]}x${newSize[1]}&quot; &amp;&amp;\n                return 0\n        else\n            echo &quot;Unable to parse modeline for ($x $y) from $mode&quot;\n            return 2\n        fi\n    else\n        echo &quot;\\`$x $y' is not a valid X Y pair&quot;\n        return 1\n    fi\n}\n</code></pre>\n"}, {'answer_id': 47251869, 'author': 'Will Berger', 'author_id': 8928866, 'author_profile': 'https://Stackoverflow.com/users/8928866', 'pm_score': 4, 'selected': False, 'text': '<p>Guys this is really simple.</p>\n\n<p>login via <code>ssh</code> into your pi</p>\n\n<p>execute </p>\n\n<pre><code>vncserver -geometry 1200x1600\n</code></pre>\n\n<p>This will generate a new session <code>:1</code></p>\n\n<p>connect with your vnc client at <code>ipaddress:1</code></p>\n\n<p>Thats it.</p>\n'}]
['https://Stackoverflow.com/questions/15816', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1084/']