đŸ’Ÿ Archived View for tilde.pink â€ș ~ssb22 â€ș vnc-magnification.gmi captured on 2023-01-29 at 17:10:28. Gemini links have been rewritten to link to archived content

View Raw

More Information

âŹ…ïž Previous capture (2022-06-03)

🚧 View Differences

-=-=-=-=-=-=-

X11 software magnification: last resort

These notes are old: I have not tested this on recently-released distributions.

If you cannot do X11 hardware magnification, and cannot achieve what you want using a high-DPI desktop, you can still get fairly good magnification using VNC as follows. This approach takes more CPU and RAM than the hardware approach, and has some other disadvantages, but it can be better than nothing.

Contents:

The x11vnc method

The idea is to run your desktop on a VNC server, and get a VNC client to display a magnified image of this.  Few of the free VNC clients have unlimited magnification functionality, so we use x11vnc (a VNC server for real X servers) to magnify another X-based VNC server.

This method is usually quite fast and allows you to scroll around a large virtual desktop.  It assumes that you are using a Unix-based terminal.  If you are using X11 remotely from a non-Unix terminal then see below.

1. Using your package manager or otherwise, install the VNC server program (vncserver or vnc4server or tightvncserver), the TightVNC viewer program (xvncviewer or xvnc4viewer or xtightvncviewer), and x11vnc. (See here if you need to update packages offline.)

x11vnc patch for large mouse cursors

patch x11vnc/x11vnc.c x11vnc.diff
CPPFLAGS=-DBIG_CURSOR make -e

instead of make. Newer versions have this functionality integrated and you can use (e.g.) -scale_cursor 4:nb on the x11vnc command line.

2. Give yourself a VNC password by using the vncpasswd command.

3. Start the VNC server by using a command such as

vncserver :2 -geometry 1052x864 -depth 16

4. Quit the VNC server (e.g. use killall Xvnc Xrealvnc Xtightvnc); this first run was only to create the initial .vnc/xstartup file and does not need to be done every time.

5. Edit the .vnc/xstartup file and add the line:

x11vnc -display :2 -rfbport 5903 -forever -scale 2:nb &

where the 2 after the -scale is the scale factor you want (the :nb means avoid blurring, which gives a clearer image when using integer scale factors).

6. If you have x11vnc version 0.7.2 or newer, add -scale_cursor 4:nb to the above command line (the 4 is how much you want the mouse cursor to scale in relation to the *unmagnified* screen).

7. Note:If the .vnc/xstartup file was not present, then you’re probably using Xrealvnc instead of Xvnc, in which case it will look at your Xsession on startup; if you’re using a real X server as well then you’ll have to script some way of distinguishing between the two (perhaps by checking the DISPLAY environment variable).

8. Start the VNC server again using the above command.

9. Connect to the magnified display using the command

xvncviewer -fullscreen :3

10. You can disconnect and reconnect the viewer as you wish. To shut down the desktop, do killall Xvnc Xrealvnc Xtightvnc.

11. If the desktop was completely blank, or not to your satisfaction, then you may need to edit the .vnc/xstartup file before starting the server again.

12. You might want to put the above into your .xsession and avoid running a window manager outside the VNC client, so that all your keypresses reach the window manager on the VNC server (but remember to add a sleep 2 to let the server start before running the viewer).

13. If possible, enable backing store in your X server by having the line Option: "backingstore" added to the Device section of XF86Config and restart the X server. This will improve the responsiveness of scrolling around the desktop. (If it takes time to repaint the screen when you scroll then that means backingstore has not been enabled properly.)

Note: Any setxkbmap command (to change the keyboard e.g. for Dvorak) may not work unless it is sent to the *real* display.  xmodmap should work however.

Windows VNC Viewer version 3

One of the few free VNC clients that can magnify is version 3 of vncviewer.exe.  Note that this is an old version; newer versions introduced a charge for the magnification functionality (it’s still free in the Windows version of TightVNC but the range is more limited).  This old vncviewer.exe works in Wine, but is slower and won’t let you drag the screen around a large virtual desktop.  It can sometimes blur the magnification too, even with integer magnification factors.  It may however be useful if for some reason you can’t get x11vnc to work.

version 3 of vncviewer.exe

1. Give yourself a VNC password by using the vncpasswd command.

2. Start the VNC server by using a command such as

vncserver :2 -geometry 640x480 -depth 16

The geometry (in the above example, 640x480) should be at most half of your screen’s resolution, so if your resolution is 1280x1024 then your maximum geometry is 640x512. (If you want to magnify three times, choose one third instead of half, and so on.) Any larger and you will have to scroll around the desktop using scrollbars, which can be awkward.

3. Now run

wine vncviewer.exe

(or run it under Windows) and a small dialogue box should appear.  In Wine it is possible that the text in the dialogue box will not display; don’t worry about this.

4. Double click on the text box and type the server you want to connect to; this is localhost:2 for the above example.  Now press the button on the bottom right to bring up the Settings dialogue. Find the check box that has two small text boxes immediately to the right of it, and check it. Double click on the first text box to the right of it and type 2 (the magnification factor). Press Enter, then click the top button.

5. If the connection is successful, you will now be prompted for your VNC password. Type it and press Enter.  The magnified desktop should now appear.

6. If you know what you’re doing you can use a remote server, tunneled over SSH if necessary; in this case it’s also better if you have the old version 3 of the server, otherwise the version 3 client will blur its magnification more often, or you can try TightVNC instead (and you get better compression if you have the TightVNC versions of both viewer and server).

7. You can disconnect and reconnect the viewer as you wish. To shut down the desktop, do killall Xvnc Xrealvnc.

8. If using X11 locally (rather than Windows), you might want to put the above into your .xsession and avoid running a window manager outside the VNC client, so that all your keypresses reach the window manager on the VNC server. This is especially the case because you will be doing a lot of keyboard navigation due to the lack of being able to drag around the desktop. (Choose a window manager with many shortcuts, e.g. FVWM2, to run on the VNC server.)

NX Client and coLinux

When working on a remote desktop over a limited-bandwidth connection, you may want to use nomachine.com’s NX Client instead of VNC.  However it seems that NX Client can’t very easily magnify the desktop (and magnifying it at the remote end using the above method will slow down NX considerably), so you may want to run the NX client on a local VNC server and then use one of the above methods to enlarge that local VNC server.

If your local machine is Windows then setting up an off-display VNC server can be difficult.  But if you have administrative access to the system then (if the system won’t run Linux) you might be able to install CoLinux:

1. Download the stable release from colinux.org and go through the installation wizard (I chose the Debian image)

2. After installation, look in C:\Program Files\coLinux, decompress the .1gb.bz2 disk image, and rename it to “root_fs”.

3. Look in control panel’s Network Connections for “Local Area Connection” (or whatever your default outgoing Internet connection is), right-click on it and choose Properties, Advanced, check the “Allow other users...” box and in the drop-down box choose the new “Local Area Connection 9” (which is a virtual connection between the host Windows OS and the guest Linux OS). This will allow coLinux to use your outgoing Internet connection. Now run coLinux like this:

colinux-daemon.exe kernel=vmlinux cobd0=root_fs root=/dev/cobd0 \
hda1=:cobd0 eth0=tuntap,"Local Area Connection 9" mem=512 -t nt

(you may want to put that in a batch file.) The initial root password is “root”, and you’ll have to type in qwerty regardless of your keyboard map; however you can do “loadkeys dvorak” once logged in, if you want to type Dvorak or any other layout.  (To shut down the virtual Linux system, just give it a halt command.)

4. You may need to edit the APT configuration (nano /etc/apt/apt.conf.d/70debconf) and add the following lines:

APT::Cache-Limit 12582912;
APT::Force-LoopBreak true;

then save and exit, and do apt-get update (it may give some 404 errors which can be ignored as long as the main mirrors respond OK).

5. If your first apt-get command goes wrong, try this:

echo '#!/bin/bash' > /usr/sbin/update-rc.d
chmod +x /usr/sbin/update-rc.d
apt-get -f install

and then repeat the apt-get command.

Once you’re up and running with CoLinux, you can apt-get the vncserver package; be sure to get the fonts packages also.  Put exec /usr/NX/bin/nxclient into .vnc/xstartup (or .Xsession if appropriate, see note above), then add the above x11vnc command before it (if you’re using x11vnc for the magnification, which is the recommended method).  If your Windows VNC client is TightVNC then you may need to add -rfbauth ~/.vnc/passwd to the x11vnc command line because some versions of TightVNC will hang if the server doesn’t need authentication.  If the NX server is on a VPN then you may find that coLinux can’t see this VPN, so you’ll need to set up an SSH tunnel and tell nxclient to connect to that instead, and .vnc/xstartup may be a good place to put the appropriate ssh command; if you’ve set up an RSA identity then you should just need something like ssh -N -l userID -L localhost:8222:nx-host:22 ssh-relay-host & (you may also want to include an xsetroot -solid darkblue command so you don’t have to look at a checkered background if the connection is delayed).

Finally, start the VNC server by using a command such as

vncserver :2 -geometry 480x300 -depth 16

You may wish to add an echo command after that, reminding you to connect the VNC client to the IP address of the coLinux machine, display 3.

If your VNC client does not support bump scrolling, then the geometry should be half the screen’s resolution (assuming the magnification factor is 2 as it is in the above x11vnc command).  This may lead to a very restrictive display.  If nxclient says “press Next to continue” but the Next button is off-screen, you can just press Enter, but once you’re on the remote desktop, you may find that some applications give you dialogue boxes that are too big for the screen. If your VNC client supports bump scrolling then you can multiply this reduced geometry by between 1.6 and 1.8 (i.e. make it 80-90% of the screen’s resolution if the magnification factor is 2) and then you’ll be able to pan around a virtual desktop.  (You probably don’t want to make the virtual desktop any larger than 1.6-1.8 times the screen size, otherwise you may “get lost” since even a full-screen window can disappear too easily.)

TightVNC 1.3.9 under Windows supports bump scrolling in full-screen mode, but it’s so fast that you’ll probably only be able to position the display on a corner.  If you need a more steady scrolling speed, try RealVNC Free Edition 4.1’s full-screen mode (you might want to turn off ‘Render Cursor Locally’ in the RealVNC Options, because x11vnc displays one).  I find that neither of these options are as good as bump scrolling in real X11.  You might want to have two configurations, one with a small geometry for normal use and another with a larger geometry for when you need to configure applications that have large dialogue boxes; you will however have to re-login to the remote machine each time you change between these configurations.

Legal

All material © Silas S. Brown unless otherwise stated. Debian is a trademark owned by Software in the Public Interest, Inc. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Unix is a trademark of The Open Group. VNC is a registered trademark of RealVNC Limited. Windows is a registered trademark of Microsoft Corp. Zoom is a trademark of Zoom Video Communications, Inc. Any other trademarks I mentioned without realising are trademarks of their respective holders.