ICC profiles and “startx” on FreeBSD

  • Thread starter Jean-Sébastien Pédron
  • Start date
Status
Not open for further replies.
J

Jean-Sébastien Pédron

Guest
Beyond photography, I find that a calibrated screen is more comfortable to use, especially if you have two or more monitors with uneven panels and colors rendering.

You can buy a professional colorimeter for a not-so-small amount of money, but fortunately, there’s an open-source alternative. Richard Hughes developed ColorHug, a free open-source colorimeter that you can build yourself or order from him. I bought one myself shortly after it was released. It gives very good results, comparable to professional devices.

To calibrate the screen, FreeBSD lacks the appropriate applications in the Ports tree. The ColorHug is provided with a modified Fedora live CD with all the required programs installed and configured. Just boot your computer using this CD, plug the device and the wizard starts automatically, offering you to calibrate all connected monitors. The process is quite straightforward and takes from a few minutes to 20-25 minutes, depending on the accuracy you want. When it’s finished, you have your shiny new profile(s) in ~/.local/share/icc. Profiles are named after monitor’s name and the date of the calibration. You need to copy those files to the same location on your FreeBSD desktop.

Now, you need to configure your computer to use the generated profile(s). GNOME, KDE and any other modern desktop environment come with display configuration tools which are easy to use. For those preferring a more lightweight environment and startx(1), things are a bit more complicated. Here is what I had to do.
  1. ICC profiles are managed by colord (graphics/colord). This daemon is started by D-BUS automatically. However, it seems that, after a fresh install, the service fails to start as reported in bug 197946 by several users of darktable. Running the service manually once “fixed” the problem for me:
    /usr/local/libexec/colord

  2. colord finds ICC profiles located in ~/.local/share/icc without further configuration. However, monitors are probed and managed by the X.Org server so another tool is required to declare all monitors in colord during session startup. I used xiccd, compiled from source (I need to make a port for it).

  3. Now, you need to start xiccd but PolKit and ConsoleKit get in the way as soon as xiccd tries to communicate with colord. Debugging this is where I spent most of the time… So here is the solution:
    • ConsoleKit is started by a login manager such as XDM, GDM, KDM and so on. If you don’t use one, you need to enable ConsoleKit in /etc/pam.d/login:
      Code:
      # ConsoleKit.
      session  optional  /usr/local/lib/pam_ck_connector.so  nox11
    • To test if ConsoleKit works, log out and log in again on the console and run ck-list-sessions. You should get something like:
      Code:
       Session1:
          unix-user = '...'
          realname = '...'
          seat = 'Seat1'
          session-type = ''
          active = TRUE
          x11-display = ''
          x11-display-device = ''
          display-device = '/dev/ttyv0'
          remote-host-name = ''
          is-local = TRUE
          on-since = '2015-04-06T08:12:57.167178Z'
          login-session-id = ''
          idle-since-hint = '2015-04-06T08:13:27.293605Z'
      The “active = TRUE” line is the important one.

    • You need to start your X session with ConsoleKit. Modify your ~/.xinitrc to start your session with ck-launch-session:
      Code:
      exec ck-launch-session dbus-launch --exit-with-session ~/.xstart
      dbus-launch starts D-BUS under the ConsoleKit session and ~/.xstart (of course, choose the name you want) is a script running all applications requiring a working D-BUS and ConsoleKit environment.

    • My .xstart launches xiccd, loads ICC profiles and starts a window manager:
      Code:
      #!/bin/sh 
      
      set -e
      
      if [ -x $HOME/Projects/graphics/xiccd/install/bin/xiccd ]; then
              # xiccd, compiled from source, is present, let's start it.
              $HOME/Projects/graphics/xiccd/install/bin/xiccd &
      
              # It takes some time to declare all screens in colord. Wait here
              # until colord knows about the laptop's monitor.
              #
              # To know the name of the monitors, use "colormgr get-devices".
              while ! colormgr get-devices | grep -q xrandr_LVDS_(...); do 
                      sleep 1 
              done 
      
              # Load the ICC profile for the laptop's monitor.
              #
              # To list the ICC profile IDs, use "colormgr get-profiles".
              colormgr device-add-profile 
                  /org/freedesktop/ColorManager/devices/xrandr_LVDS_(...) 
                  /org/freedesktop/ColorManager/profiles/icc_(...)
      
              # Do this again for each possible external screens.
              if colormgr get-devices | grep -q xrandr_EA244UHD_(...); then 
                      # NEC EA244UHD. 
                      xrandr --output LVDS --off 
                      xrandr --output HDMI-0 --mode 1920x1080 --rate 60 
      
                      colormgr device-add-profile 
                          /org/freedesktop/ColorManager/devices/xrandr_EA244UHD_(...) 
                          /org/freedesktop/ColorManager/profiles/icc_(...)
              fi 
      
              if colormgr get-devices | grep -q xrandr_SONY_TV_(...); then 
                      # Sony Bravia KDL-40WE5. 
                      xrandr --output LVDS --off
      
                      colormgr device-add-profile 
                          /org/freedesktop/ColorManager/devices/xrandr_SONY_TV_(...) 
                          /org/freedesktop/ColorManager/profiles/icc_(...)
              fi
      fi
      
      # Start window manager.
      exec awesome

Now, after startx, all monitors display the same colors!

With a single monitor to manage, oyranos (graphics/oyranos) was working for me. There is no dependency to colord, ConsoleKit or PolKit and is way simpler to use. However, it didn’t want to manage my external monitor (or two monitors at a time, I don’t know). This made an opportunity to play with colord. I just didn’t expect ConsoleKit or PolKit to join the party :)

4s0bZNHqlcI


Continue reading...
 
Last edited by a moderator:
Status
Not open for further replies.
Back
Top