Full Screen Color Correction in Linux with ICC Profile

Full Screen Color Correction with KWin/KDE or Compiz

Dmitry Safonov
7 min readMay 11, 2021

Introduction

As a user of a Dell XPS 15 laptop with a wide gamut 4k display running Linux, I faced an annoying problem with oversaturated colors. Everything looked unnatural on a laptop screen compared to external displays which I attached to the laptop. It took some time to understand the real reason of this problem and implement a working solution. This post may help those who found themselves in a similar situation.

Note for Windows Users

Recently I came along this article by Adam Simmons which describes some ways to achieve full screen color correction at the GPU driver level on Windows (applicable for NVidia and AMD). I did not test them, however.

TL;DR: Full Screen Color Correction with KWin in KDE or Compiz

If you’re lucky and your monitor has some kind of switch to enable sRGB emulation mode, use it.

If you’re not (like me), then you need to setup full screen color correction. First, you will have to create/find an ICC profile for your display.Then you can setup transparent full screen color correction on window manager level. Currently I’ve found two options:

  1. Install XFCE + Compiz 0.9 + xiccd + Compiz Color Management plugin for full screen color correction
  2. Install KDE, manually compile KWin with a patch which provides “ICC Color Correction” desktop effect, make newly compiled kwin replace default kwin on system startup, enable and configure the effect.

Unfortunately, both options will require some technical skill: you will have to play a game of finding the right set of development packages required for compilation, and for option 2 you may have to dig into the code and adapt the patch to the version of the KWin used in your KDE version.

Internet says that full screen color correction will be soon available out of the box on KDE + Wayland, but at the time of writing it was not ready and I ended up with option 2 because for me KDE felt more mature and polished then XFCE + Compiz.

Background of the Problem

  • Digital representation of a color (e.g. #FF0000 (or 255,0,0), which corresponds to “red” in web) is a relative concept, something like “the brightest red”. Different monitors will produce different colors when you “ask” them to show “the brightest red” (you can read more about color spaces, color profiles and color management).
  • Most graphical content (web images, icons and colors of GUI elements in the apps we use) is designed for displays working in so called sRGB color space. Most of the displays available on the market today are sRGB displays. So the owner of a “standard” display will see the colors as supposed by designer/photographer/etc.
  • There are so called “wide gamut” displays, which can show significantly more colors then “sRGB” displays. “The brightest red” on those displays looks completely different then “the brightest red” on sRGB displays. Some kind of conversion is required to present sRGB content on wide gamut displays.
  • To implement this conversion, it is required to know exact color characteristics of the display. Those characteristics can be stored in a special file called ICC profile.
  • ICC profiles can be created during so called display profiling procedure which requires special hardware (colorimeter) and software (like DisplayCAL). Profiling software will evaluate your display using hardware tool and build an ICC profile with display’s characteristics.
  • Display vendors may also embed “factory-default” ICC profile into display hardware (EDID).
  • Because it is non-trivial to create an ICC profile, some people share profiles for their displays on internet, e.g. at https://www.tftcentral.co.uk/articles/icc_profiles.htm. It’s worth noting that it’s not quite right to reuse profile created for another display (event of the same model), because each display device is unique and requires it’s own profiling. But for non-professional goals (like getting a more or less normal presentation of sRGB content on wide gamut display) a profile from the internet may provide valuable results.
  • A small number of Linux applications (e.g. Firefox, Gimp) can be explicitly configured to utilize ICC profiles to adapt their picture for output device.
  • But generally in Linux all content goes to the display without any conversions, which produce an unpleasant picture when showing sRGB content (i.e. almost everything) on a wide gamut display.

Solution Idea

  • Linux desktop environments usually have a component called “window manager” to provide functionality of moving/resizing windows. Window manager is a good place to implement full screen color correction. Some existing window managers have plugins which provide full screen color correction based on ICC profile of the display.

Color Correction with Compiz

  • There is an old but feature rich and extendable window manager Compiz, which has a plugin for implicit color correction for all windows(with possible exceptions based on window name).
  • It is worth noting that there are two major versions of compiz (0.8 and 0.9) which are maintained in parallel (see more about this at Arch Wiki page about Compiz). Each Compiz version has it’s own color management plugin: 0.8 branch has Compicc, and 0.9 branch has Compiz-CMS).
  • I succeeded with Copmiz 0.9 and Compiz-CMS. I tried Compiz 0.8 and Compicc as well, and they seem to get the job done, but it’s more challenging to compile Compicc from the sources in a modern linux environment (e.g. Fedora 33) due to many (and sometimes outdated) dependencies, and it is a bit harder to configure.
  • Not every desktop environment can work with Compiz 0.9. The main usable candidates which I’ve found were Ubuntu’s Gnome Flashback and XFCE, the later available in many distros.
  • I found XFCE more convenient then Gnome Flashback.
  • So, the solution is consisting from the following items: obtain an ICC profile for the display, install XFCE, install Compiz 0.9, install Compiz-CMS plugin, configure Compiz-CMS to use the ICC profile for full screen color correction.

Installation Hints for XFCE + Compiz

XFCE installation is out of scope of this article. A few words on XFCE configuration for HiDpi display:

  • Go to “Applications/Settings/Appearance/Fonts” and set custom DPI setting to 212 (or other number which you will be comfortable with). I did not use the “Window Scaling” option from the neighbor “Settings” tab because some software worked better with DPI setting
  • Right-click on the middle of top panel, navigate to “Panel/Panel Preferences”. Increase “Row size (pixels)” on the “Display” tab and “Fixed icon size (pixels)” on the “Appearance” tab.
  • Log out/Log in for changes to take the full effect.

Next, it is necessary to install Compiz. Fedora repositories provide only Compiz 0.8. We require Compiz 0.9. We will have to build it from source. Download latest tar with sources from https://launchpad.net/compiz/, at the time of this writing the latest version was 0.9.14.1, compile.

Compiz is very (too much) configurable, and it is required to enable some really important features before starting. Run “ccsm” in terminal, it will open Compiz configuration GUI. Enable “Window Decoration”, “Move Window”, “Resize Window” as a minimum. There are a lot of different plugins for different things, e.g. Alt+Tab window switching/etc.
After minimum configuration, navigate to the folder with compiled binary. To start compiled compiz, execute the following:

compiz --replace

This can be put to autostart. Then it is required to download, compile and install Compiz CMS Plugin. It fetches ICC profile for the display from colord. XFCE has a color profile settings dialog which can be used to assign specific ICC profile to a display, but it is necessary to install xiccd package to make your display appear in a list of the displays in that dialog.

Color Correction with KWin (KDE)

  • I was not completely satisfied with Compiz because it required too much tweaking to provide good user experience, so I continued my search and stumbled upon the the merge request proposing a new desktop effect for ICC Color Correction for KWin window manager, which is a part of KDE
  • I was able to locally apply that merge request to a KWin sources of the version which was used in my distro (Fedora 33), however the merge request was is a little bit old at that time and it was required to alter the code (change prototypes of virtual functions of the effect to match evolved prototypes of those functions in parent class). It seems that later newer version of the merge request appeared.
  • Finally, I got this effect working, and since than I live happily with KDE + Custom KWin. Thanks to Vitaly Filippov.

Installation Hints for KWin (KDE)

  • Install KDE
  • Find out the version of kwin by running
kwin --version
  • Checkout KWin sources for that version
  • Download the diff for the commit included in merge request
  • Apply the diff, compile (this could be a tricky exercise for non-experienced users)
  • Navigate to a folder with compiled binaries, run
QT_PLUGIN_PATH=`pwd` systemsettings5

This will open the system settings dialog, find desktop effects, there you should see an “ICC Color Correction” effect in the list. Enable it and configure. You will not notice changes yet.

  • Run from the same folder
QT_PLUGIN_PATH=`pwd` ./kwin_x11 --replace

You should notice that color correction is working. You can put later script to autostart.

Conclusion

Unfortunately, full screen color correction is pretty hard to setup these days. For this reason, I would not recommend anyone to buy a wide gamut display for usual day to day work (except for the cases when this is a direct requirement). Probably things will be better with KDE + Wayland soon thanks to the https://invent.kde.org/plasma/kwin/-/issues/11. But for now, people with technical skill may use options listed in this article.

--

--

Dmitry Safonov
0 Followers

Software engineer, IT enthusiast