tps.dock

Logic related to the UltraBase® docks.

tps.dock.dock(on, config)

Performs the makroscopic docking action.

Parameters:
  • on (bool) – Desired state
  • config (configparser.ConfigParser) – Global config
Returns:

None

tps.dock.is_docked(config)

Determines whether the laptop is on a docking station.

This checks for /sys/devices/platform/dock.*/docked. In issue 129 it became apparent that this is not a sufficient solution. Therefore a configuration option allows to alternatively check for USB devices that are present.

Returns:True if laptop is docked
Return type:bool
tps.dock.main()

Command line entry point.

Returns:None
tps.dock.select_docking_screens(internal, primary='', secondary='')

Selects the primary, secondary, and remaining screens when docking.

If primary or secondary is not the name of a connected screen, then select an appropriate screen from the connected screens. External screens are prioritized over the internal screen, and primary is prioritized over secondary. Warn the user if primary or secondary is a non-empty string and the screen is not connected.

If no external screens are connected, then set primary to the internal screen, and set secondary to None.

Parameters:
  • internal (str) – Name of the internal screen
  • primary (str) – Name of primary screen, or an empty string
  • secondary (str) – Name of secondary screen, or an empty string
Returns:

(primary, secondary, [other1, …])

Return type:

tuple

For example, when only LVDS1 is connected:

>>> select_docking_screens('LVDS1', '', '')
('LVDS1', None, [])

When LVDS1 and VGA1 are connected:

>>> select_docking_screens('LVDS1', '', '')
('VGA1', 'LVDS1', [])
>>> select_docking_screens('LVDS1', 'LVDS1', '')
('LVDS1', 'VGA1', [])

When LVDS1, VGA1, and HDMI1 are connected:

>>> select_docking_screens('LVDS1', '', '')
('HDMI1', 'VGA1', ['LVDS1'])
>>> select_docking_screens('LVDS1', 'VGA1', '')
('VGA1', 'HDMI1', ['LVDS1'])
>>> select_docking_screens('LVDS1', '', 'LVDS1')
('HDMI1', 'LVDS1', ['VGA1'])

Note that the default order of VGA1 versus HDMI1 depends on the output of xrandr. See tps.testsuite.test_dock.SelectDockingScreensTestCase for more examples.