Ubuntu – How to reverse colors for the current window in gnome shell

gnomegnome-shellxorg

I dislike that most websites use a black font on white background for their sites, as it gets too tiresome for me to read.

Back in the days of 11.04, using Gnome2 with compiz, there actually was a Negative feature that could negate the content of any window, making the background black and the font white. Much easier on the eyes for me.

Yet since 11.10, using gnome shell with mutter, I have no idea if there is something alike out there.

Hence my question: How do I negate the currently active window in gnome shell?

I am not interested in alternative methods, e.g. user styles. I am aware of their existence but I find it much easier to just invert the screen by the hit of a key shortcut. I also want the solution to be application-agnostic. As I also from time to time would want to invert libre-office or some other glaringly white application.

Best Answer

To invert the entire screen you can use the program xcalib:

xcalib -invert -alter

From the xcalib man page

xcalib loads 'vcgt'-tag of ICC profiles to the X-server using the XVidMode Extension in order to calibrate your display.

That means it does not depend on compiz being used.

You can install it using sudo apt-get install xcalib. To make it more convenient assign a keyboard shortcut opening the Keyboard settings.

Keyboard Settings for adding manual shortcut

There, navigate to shortcuts. Add a custom shortcut by pressing the plus button, add the name and the command. It will be disabled by default, so assign a shortcut by clicking on Disabled and perform the wanted shortcut, e.g. meta + i

Before:

before

After xcalib -invert -alter was launched (mapped to <meta-i>:

after

Pressing it again restores to the normal not inverted screen.