Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to have an inverse color effect (light to dark) like 'negative' in compiz, but without compiz, and only for one window (like compiz's Super+N) .

Is there a way to get a similar effect (toggled by a key combo preferably) without compiz? I can invert colors for the entire desktop with xcalib -I -a, but I can't restrict it to a single window.

share|improve this question
Maybe related to this post:… – Sh3ljohn Aug 20 '13 at 16:27
i've been using the negative window option from compiz window manager and it works very well also. – stats-hb Mar 11 at 22:26
up vote 13 down vote accepted

As far as I know... to achieve that, you will need help of a Window Compositor.
You can try to install a lightweight standalone compositor like Compton.


Compton is a lightweight compositor for X, and a fork of xcompmgr-dana.

According to the Man Pages Compton has an option to invert colors in a window.


compton --invert-color-include <CONDITION>

The condition could be the WM_CLASS of a window, to find the "WM_CLASS" in a window you can run the command xprop

  • xprop | grep WM_CLASS

Then the cursor will be a "Cross" and you can click in the window you want, to find the WM_CLASS.

Now you should have something like this:

WM_CLASS(STRING) = "leafpad", "Leafpad"

enter image description here

The second string should be the WM_CLASS "Leafpad".
So, to invert the colors of the Leafpad editor you should run:

  • compton --invert-color-include 'class_g="Leafpad"'

You do not need to run compton all the time, you can run it when you need to invert the colors of a window.

NOTE: In this example I'm running Lubuntu 13.04 with openbox as window manager but without compositor by default.

To install Compton

This compositor has it own PPA

1) To install compton open a Terminal and type:

  • sudo add-apt-repository ppa:richardgv/compton
  • sudo apt-get update && sudo apt-get install compton

In this example I will create a basic Bash script (I am not an expert in scripts) to detect the active window and invert its colors.

2) Create the script.

  • sudo apt-get install xdotool
  • mkdir ~/Scripts
  • nano ~/Scripts/

The content of the script:

#! /bin/bash

if [ "$(pidof compton)" ];
            pkill compton

        ID=$(xdotool getactivewindow)
        CLASS=$(xprop -id "$ID"  | grep "WM_CLASS" | awk '{print $4}')
        compton --invert-color-include "$COND" &

Basically the script will check if compton is running, if it not running xdotool will find the window id of the active window, with the id xprop will find the WM_CLASS, then with the WM_CLASS it will create the condition and finally will run compton with the condition as argument.

Make the script executable.

  • chmod +x ~/Scripts/

In my case I will create a soft link to the /usr/bin/ directory with the name "invert-color"

  • sudo ln -s ~/Scripts/ /usr/bin/invert-color

3) create a Keyboard Shortcut
e.g: Ctrl+Alt+U (In Lubuntu you should edit the lubuntu-rc.xml file)

  • leafpad ~/.config/openbox/lubuntu-rc.xml

Add the following Lines:

<!-- Launch invert-color activewindow on Ctrl + Alt + U-->
<keybind key="C-A-U">
  <action name="Execute">

Finally you can Logout and Login to see the changes in the keyboard shortcut.

My intention is when I need to invert the colors in the active window I can do it with the Shortcut Ctrl+Alt+U.If I want to go back to the normal colors I will press again the shortcut and the script will detect the compton is running therefore the pkill command will kill the process compton.
So in this way I will only run the compositor when I need it.

Here you have a few screenshots:

enter image description here

enter image description here

enter image description here

enter image description here

Hope it helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.