Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically invert screen colors in Linux

Tags:

linux

ubuntu

In Ubuntu, for example, you can use Super-M to invert the screen colors (requires desktop effects, see [1]). Other OSes have similar abilities, although I'm not really concerned with anything other than Linux.

Which API should I look into if I want to write a simple program that, when run, inverts the screen colors?

The language that I use the API from doesn't particularly matter to me. I am familiar enough with C/C++/Bash/Perl/Python that I can hack this up in whatever language has the easiest access to this API. Working on Ubuntu is required, working on other similar *nixes is not terribly important.

[1] https://help.ubuntu.com/community/KeyboardShortcuts#Desktop%20Effects%20enabled%20shortcuts

like image 903
Elliott Slaughter Avatar asked Aug 23 '10 21:08

Elliott Slaughter


People also ask

How do you invert colors on Linux?

If you have Compiz, open CompizConfig Settings Manager and enable Negative. This will allow you to invert colors of a window (default shortcut is Super+n ) or the whole desktop (default shortcut is Super+m ).


1 Answers

You could use xcalib to do what you want.

For example, a simple bash script to invert the screen colors would look like this:

#!/bin/bash
xcalib -invert -alter
like image 173
mtvec Avatar answered Dec 01 '22 03:12

mtvec