GNOME 3 color profile and screen brightness

Lesson learned: Next time I when face a problem with some desktop software, first I will do is dbus-monitor.

I decided to switch my current desktop environment from Cinnamon to GNOME 3. As a by product, I created a new color profile with my spyder3. The old one was from 2014, and it was definitly the time to create a new one. Therefor, GNOME shipps gnome-color-manager. So I set my display to my "photo-editing"-brightness and started measuring.

So far, everything worked fine. I even only had to touch gnome-tweak-tool once to set my favorite fonts.

I did everything in one session, without logging out or rebooting. During this time, I also created my shortcuts to switch the screen brightness between "working"- and "photo-editing"-mode. In the first shot, they worked. The only issue: The brightness slider did not move to the correct position.

At this point I was done! Just wanted to compare the console fonts with those, set in Cinnamon. So I logged out, switched the session to Cinnamon, took a screen shot, and switched back to GNOME.

On login it happened. GNOME set the screen brightness to 100%. I I set the brightness manually using the brigness slider. Still the same problem. Searching the web, did not really help. I was told to place a startup desktop-file in ~/.config/autostart/. But this did not work very reliable. One thing I did. Killing the gnome-settings-daemon, since in my excperience, this could be the cause. Turns out. gnome-settings-daemon was responsible. Next, I tried to find some gsettings in dconf, without any success.

So I got the source code of gnome-settings-daemon, found the responsible lines of code within a few minutes. During walking up the possible call tree, I did not find an explicit call. But I discovered the dbus api of the power-plugin. However. I started dbus-monitor, and pressed the brightness buttons, to get an idea who the api is used. Mainly to be able to put a filter on dbus-monitor.

$ dbus-monitor --session "path=/org/gnome/SettingsDaemon/Power"

This only shows calls to the power-thing. I used path in favor of interface, since this also shows property changes.

Killing gnome-settings-daemon showed a property change of brightness to 100%.

signal time=1453584221.013391 sender=:1.579 -> destination=(null destination) serial=214 path=/org/gnome/SettingsDaemon/Power; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.gnome.SettingsDaemon.Power.Screen"
   array [
      dict entry(
         string "Brightness"
         variant             int32 100
      )
   ]

Form this on, I knew the call, and grepped again the source code of gnome-settings-daemon. And that was the missing piece. I found a dbus call in plugins/color/gsd-color-state.c … the color manager part of gnome-settings-daemon. However. I discovered the following rows:

// if output is a laptop screen and the profile has a
// calibration brightness then set this new brightness
brightness_profile = cd_profile_get_metadata_item (profile,
                                                   CD_PROFILE_METADATA_SCREEN_BRIGHTNESS);
if (gnome_rr_output_is_builtin_display (output) &&
    brightness_profile != NULL) {
        // the percentage is stored in the profile metadata as
        // a string, not ideal, but it's all we have...
        brightness_percentage = atoi (brightness_profile);
        gcm_session_set_output_percentage (brightness_percentage);
}

The comment pointed me directly to the solution of my problem. I took a look into the icc profile, and voila, metadata said "Screen Brightness: 100".

I only had to remove this metadata of my profile (located in ~/.local/share/icc).

$ cd-fix-profile PROFILE.icc md-remove SCREEN_brightness

\o/

However. I am pretty sure, the screen was on the correct brightness level (39%) when I started to create the profile.

And again. I faced a little, but annoying, problem, and was able find the cause. And this, just because GNOME is open source!

Above, I wrote about the issue of the "not moving brightness slider". As a by-product of the walk through gnome-settings-daemon, I was able to change my brightness-switch-command, to use the dbus calls.

Setting the brigness to 9% (which is my working-mode, most of the time):

$ dbus-send --session --type=method_call \
  --dest="org.gnome.SettingsDaemon" \
  /org/gnome/SettingsDaemon/Power \
  org.freedesktop.DBus.Properties.Set \
  string:"org.gnome.SettingsDaemon.Power.Screen" \
  string:"Brightness" \
  variant:int32:9

Setting the brightness to 39% (for photo-editing):

$ dbus-send --session --type=method_call \
  --dest="org.gnome.SettingsDaemon" \
  /org/gnome/SettingsDaemon/Power \
  org.freedesktop.DBus.Properties.Set \
  string:"org.gnome.SettingsDaemon.Power.Screen" \
  string:"Brightness" \
  variant:int32:39

Wohooo, and yet it moves :D

Flattr this!