Back to Silas S. Brown's home page | X11 configuration

VNC with inverted colours

These instructions are no longer being maintained, because modern TFT monitors are not so bad to look at when running one of the few applications that cannot be inverted. The instructions below may or may not work on newer versions of Debian, e.g. you may have to replace vncserver with vnc4server.
People with certain eyesight conditions find bright backgrounds difficult to work with, but some applications cannot be configured otherwise. If you have to use one of those applications, it might help a little to use a program that intercepts the display at a low level and inverts all the colours.  This is a last resort as the result is unlikely to be optimal.

The following hack will do this on a Linux system. It relies on VNC (Virtual Network Computing) and we will be making a small modification to the VNC viewer.

Note: This works as-is only for Debian-based distributions. If your distribution is not Debian then you need to modify this.

First, download invert-vnc.diff and save it as /tmp/invert-vnc.diff

Then paste the following into a root prompt: the lines are long):

apt-get --no-upgrade install xnest libjpeg62-dev \
  xvncviewer vncserver vnc-common libvncauth0 dpkg-dev
cd /tmp
apt-get source xvncviewer
cat invert-vnc.diff | patch vnc-*/vncviewer/desktop.c
Then, if you are using Debian 3.0 aka Woody, paste in the following (ONLY if you are using Woody):
cd vnc-*/vncviewer
gcc-2.95 -I ../include/ -I ../vncviewer/ \
  -I ../Xvnc/lib/zlib $(
    echo *.c | sed -e 's/corre.c//' \
      -e 's/hextile.c//' -e 's/rre.c//' \
      -e 's/zlib.c//' -e 's/tight.c//') \
   /usr/X11R6/lib/ \
   /usr/lib/ \
   /usr/lib/ \
   /usr/X11R6/lib/ \
mv a.out /usr/local/bin/invert-vnc
For Debian versions later than 3.0, paste the following instead of the above:
cd vnc-*
apt-get --no-upgrade install linux-kernel-headers
./configure && make && mv vncviewer/vncviewer \
Finally, paste in the following script. You might like to change the variables at the beginning, especially Geometry. Security note: all local users will be able to interfere with your X display.
cat > /usr/local/bin/run-inverted <<'EOF'

export Geometry=640x480
export VNCDisplay=98
export XnestDisplay=99

Xvnc :$VNCDisplay -geometry $Geometry -ac \
      -once -deferglyphs 16 -nolisten unix &
export vnc_server_pid=$!
Xnest -geometry $Geometry -ac \
      -nolisten tcp :$XnestDisplay &
export xnest_pid=$!
sleep 3
DISPLAY=:$VNCDisplay xsetroot -solid white
DISPLAY=:$VNCDisplay $* &
export application_pid=$!
DISPLAY=:$XnestDisplay invert-vnc \
    -encodings raw -fullscreen :$VNCDisplay &
DISPLAY=:$VNCDisplay xset s off
DISPLAY=:$XnestDisplay xset s off
wait $application_pid
kill $vnc_server_pid ; kill $xnest_pid
chmod +x /usr/local/bin/run-inverted
If you use a different keyboard layout (e.g. Dvorak) then you may need to add the appropriate xmodmap command to /usr/local/bin/run-inverted (use export DISPLAY=:$VNCDisplay first; do not send it to :$XnestDisplay or the real display).  This should go before the waitsetxkbmap is less likely to work than xmodmap.

The program is now ready for use. Use it like this (as an ordinary user, not root):

run-inverted application
where application is the command to run the application that you wish to use with inverted colours. (If you need a window manager, create a script that launches the window manager and the application and run that.)
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.
VNC is a registered trademark of RealVNC Limited.
Any other trademarks I mentioned without realising are trademarks of their respective holders.