Static Display Configuration for Mir

Static Display Configuration for Mir

Background

We have encountered a number of scenarios where users need to explicitly set the arrangement of displays on a Mir server. The motivation for this work comes from scenarios like arranging a “display wall” for signage, but I’m sure uses could also be found on the desktop.

The file format

We explored a number of options but settled on YAML. This is widely used within Canonical products and will be familiar to anyone creating snaps. Here’s an example file from my testing:

layouts:
# keys here are layout labels (used for atomically switching between them)
# when enabling displays, surfaces should be matched in reverse recency order

  default:                       # the default layout

    cards:
    # a list of cards (currently matched by card-id)

    - card-id: 0
      VGA-1:
        state: disabled        # Defaults to preferred enabled

      HDMI-A-1:
        orientation: inverted # {normal, left, right, inverted}, Defaults to normal

I hope this is readily understandable.

Using a display configuration file

With the initial implementation this feature is only available with miral-shell. I’ll be adding something similar to miral-kiosk next week.

Firstly, you need the development version of Mir from ppa:mir-team/dev:

sudo add-apt-repository --update ppa:mir-team/release
sudo apt install mir-demos mir-graphics-drivers-desktop
sudo apt install qterminal qtwayland5

Then, having made sure you have first signed into VT4 you run miral-desktop saying that you want to use a static display layout:

miral-desktop  --display-config static=static-display-layout

Here static-display-layout is just the name of a file we intend to use. The name doesn’t matter, but ensure the file doesn’t yet exist (otherwise Mir will try to use it). Exit Mir and look back at the console log, you should see something like the following:

[2018-08-24 18:08:03.506576] mesa-kms:  Output: DisplayPort-2 (disconnected)
[2018-08-24 18:08:03.506742] miral: Display config:
8>< ---------------------------------------------------
layouts:
# keys here are layout labels (used for atomically switching between them)
# when enabling displays, surfaces should be matched in reverse recency order

  default:                         # the default layout

    cards:
    # a list of cards (currently matched by card-id)

    - card-id: 0
      VGA-1:
        # This output supports the following modes: 1920x1080@60.0, 1680x1050@60.0,
        # 1280x1024@75.0, 1280x1024@60.0, 1440x900@59.9, 1280x960@60.0, 1280x800@59.8,
        # 1152x864@75.0, 1280x720@60.0, 1024x768@75.0, 1024x768@70.1, 1024x768@60.0,
        # 832x624@74.5, 800x600@75.0, 800x600@72.2, 800x600@60.3, 800x600@56.2,
        # 640x480@75.0, 640x480@66.7, 640x480@59.9, 720x400@70.1
        #
        # Uncomment the following to enforce the selected configuration.
        # Or amend as desired.
        #
        # state: enabled        # {enabled, disabled}, defaults to enabled
        # mode: 1920x1080@60.0  # Defaults to preferred mode
        # position: [0, 0]      # Defaults to [0, 0]
        # orientation: normal   # {normal, left, right, inverted}, defaults to normal

      HDMI-A-1:
        # This output supports the following modes: 1920x1080@60.0, 1680x1050@59.9,
        # 1280x1024@75.0, 1280x1024@60.0, 1440x900@59.9, 1280x960@60.0, 1280x800@59.9,
        # 1152x864@75.0, 1280x720@60.0, 1024x768@75.0, 1024x768@70.1, 1024x768@60.0,
        # 832x624@74.5, 800x600@75.0, 800x600@72.2, 800x600@60.3, 800x600@56.2,
        # 640x480@75.0, 640x480@66.7, 640x480@59.9, 720x400@70.1
        #
        # Uncomment the following to enforce the selected configuration.
        # Or amend as desired.
        #
        # state: enabled        # {enabled, disabled}, defaults to enabled
        # mode: 1920x1080@60.0  # Defaults to preferred mode
        # position: [0, 0]      # Defaults to [0, 0]
        # orientation: normal   # {normal, left, right, inverted}, defaults to normal

      DisplayPort-1:
        # (disconnected)

      HDMI-A-2:
        # (disconnected)

      DisplayPort-2:
        # (disconnected)
8>< ---------------------------------------------------
[2018-08-24 18:08:03.674614] <WARNING> mesa-kms: drmModeCrtcSetGamma failed: Invalid argument
[2018-08-24 18:08:03.674669] <WARNING> mesa-kms: drmModeCrtcSetGamma failed: Invalid argument

Cut & paste the bits between the 8>< --------------------------------------------------- lines into a new file “static-display-layout”. This gives you a template (without any options selected) corresponding to your available displays.

You can then experiment with changing the mode, position and orientation of your display outputs and re-running with the same command used above. This time it will read the file and apply the options you’ve selected.

Good luck! And let us know how you get on.

1 Like