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.cThen, 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/libXt.so.6.0 \ /usr/lib/libjpeg.so.62 \ /usr/lib/libvncauth.so.0 \ /usr/X11R6/lib/libXaw.so.7 \ /usr/lib/libz.so.1 mv a.out /usr/local/bin/invert-vncFor 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 \ /usr/local/bin/invert-vncFinally, 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' #!/bin/bash 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 EOF chmod +x /usr/local/bin/run-invertedIf 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 wait. setxkbmap 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 applicationwhere 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.)