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.
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
According to the Man Pages Compton has an option to invert colors in a window.
e.g:
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:
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"'
In some cases, you might want to invert only some windows of a program (e.g. invert the editor window, but not the "save file" dialog).
For that you can use the first of the two
WM_CLASS
strings (also called the "instance"):compton --invert-color-include '(class_g="Leafpad" && class_i="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/invert.sh
The content of the script:
Make the script executable.
chmod +x ~/Scripts/invert.sh
In my case I will create a soft link to the /usr/bin/ directory with the name "invert-color"
sudo ln -s ~/Scripts/invert.sh /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:
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:
Hope it helps.
A Gnome Shell Extension "Invert Window Color" does this without any hassle. Here is the Link.