Unity Command Line – Get Display Scale for Menu and Title Bars

unity

I did a clean clean install of 14.04 and confirmed that Display -> "Scale for menu and title bars:" is set to 1.

However some users of the application I develop report that its set to 0.875 on clean Ubuntu installs.

Main question:
How do I get the value of Display -> "Scale for menu and title bars:" from the command line? I want my application to be able to check this value and response appropriately. I realize that my application should be scale agnostic, but its not, and in the short term I can't make it so.

Secondary question:
If the default value of Display -> "Scale for menu and title bars:" can be different to 1 on a clean install, what factors effect this?

Best Answer

This setting is stored by dconf in /com/ubuntu/user-interface/scale-factor.

Use the command

dconf watch /com/ubuntu/user-interface/scale-factor

to watch how it changes when you move the scale. Note that, apparently, the scale factor displayed in the GUI corresponds to exactly 1/8 of this value, e.g., when I set the scale factor, via the GUI, to 1 for my primary display (on DisplayPort-1) the value /com/ubuntu/user-interface/scale-factor is set to

{'DisplayPort-0': 8, 'HDMI-0': 8, 'DVI-1': 8, 'DisplayPort-1': 8}

When I set the scale factor to 2 I obtain

{'DisplayPort-0': 8, 'HDMI-0': 8, 'DVI-1': 8, 'DisplayPort-1': 16}

When I set the scale factor to 0.5 I obtain

{'DisplayPort-0': 8, 'HDMI-0': 8, 'DVI-1': 8, 'DisplayPort-1': 4}

etc.

This is analogous for the other displays, of course. Do note that this is not one value, but an array of values, keyed with the display identifiers as returned by xrandr.

To change the setting via the command line, use something like

dconf write /com/ubuntu/user-interface/scale-factor "{'DisplayPort-0': 8, 'HDMI-0': 8, 'DVI-1': 8, 'DisplayPort-1': 8}"