RandR segments

class powerline.segments.randr.OutputSegment[source]
class powerline.segments.randr.ScreenRotationSegment[source]
powerline.segments.randr.output(interval=2, auto_shrink=True, hide_if_single_output=True, status_icons={'on': 'on', 'off': 'off'}, short_format="{mirror_icon} {output_count}", output_format="{output} {status_icon}", mirror_icons={'mirror': 'M', 'extend': 'E'}, mirror_format="{mirror_icon}", redraw_hook=None, auto_update=False)

Manage connected outputs, optionally detect newly (dis-)connected outputs automatically.

Requires python-xlib.

Parameters:
  • mirror_format (string) – Format used to display the mirror mode (extend/mirror) part of the segment. Valid fields are mirror_state and mirror_icon.
  • mirror_icons (dict) – Icons used in the mirror_icon field of mirror_format. Needs the entries extend and mirror.
  • output_format (string) – Format used to display outputs and information about their status. Valid fields are output and status_icon.
  • status_icons (dict) – Icons used in the status_icon field of output_format. Needs the entries off and on.
  • hide_if_single_output (bool) – Hide the segment if only a single output is connected. (Enabling this will still show the segment if there is more than one output connected, of whom only one is not turned off.)
  • auto_update (bool) – If set to true, this segment will automatically enable newly connected outputs or disable newly disconnected outputs according to the current mode. Also restarts bars appropriately.

Highlight groups used: output:mirror or output:extend or output:mirror_state or output (for the mirror mode part) and output:off or output:on or output:status or output (for the outputs).

Click values supplied: mirror_state (string) for the mirror mode part and output_name (string), output_status (string) in the remaining part.

Interaction: This segment supports interaction via bar commands in the following way. (Note that parameters given to the bar may be combined with click values.)

Bar command Description
#bar;pass_oneshot:mode:<mode/toggle> Set the mirror mode to <mode> or <toggle> it.
#bar;pass_oneshot:output:<output>:<on/off/toggle> Turn output <output> <on/off> or <toggle> its status. Restarts bars.
powerline.segments.randr.srot(output, interval=2, additional_controls=[], icons={'left': 'l', 'right': 'r', 'normal': 'n', 'inverted': 'i', 'locked': 'l', 'auto': 'a'}, format="{icon}", name="rotation", show_on_all_outputs=True, sensor_max_value=None, sensor_is_unsigned=False, hide_controls=True, rotation_hook=None, touchpad_states=None, touchpads=[], mapped_inputs=[], gravity_triggers=None, states=['normal', 'inverted', 'left', 'right'])

Manage screen rotation and optionally display some information. Optionally disables Touchpads in rotated states. (Note that rotating to the left and right states does not currently work if there is another output connected whose displayed content is not mirrored to the screen to be rotated.)

Requires xinput and python-xlib and an accelerometer.

Parameters:
  • output (string) – The initial output to be rotated and to which touchscreen and stylus inputs are mapped. (Note that this can be changed at runtime via interaction with the segment.)
  • show_on_all_outputs (bool) – If set to false, this segment is only visible on the specified output.
  • name (string) – Possible values are rotation and mode. This value is used to determine which highlight groups to use and how to populate the icon field in the format string in the returned segment. If set to any other value, this segment will produce no output.
  • format (string) – Format string. Possible fields are rotation (the current rotation state of the screen), mode (either auto or locked, depending on whether auto-rotation on the screen is enabled or not), and icon (an icon depicting either the rotation status or the auto-rotation status, depending on the segment’s name).
  • icons (dict) – Dictionary mapping rotation states (normal, inverted, left, right) and auto-rotation states (locked, auto) to strings to use to display them. Depending on the given name parameter, not all of these fields must be populated.
  • list states (string) – Allowed rotation states. Possible entries are normal, inverted, left, and right. Per default, all of them are enabled.
  • gravity_triggers (dict) – Sensor values that trigger rotation as a dictionary mapping rotation states (normal, inverted, left, right) to numbers. Defaults to {'normal': -8, 'inverted': 8, 'left': 8, 'right': -8}, meaning that a (scaled) reading of the in_accel_x_raw reading greater than 8 triggers a rotation to state left and a reading less than -8 triggers a rotation to state right. Readings of in_accel_y_raw greater and less than 8 and -8 respectively will yield a rotation to the inverted and normal states respectively.
  • mapped_inputs (string_list) – List of substrings of device names that should be mapped to the specified output. The entries in the specified list should be only substrings of devices listed as Virtual core pointer, not of devices listed as Virtual core keyboard.
  • touchpads (string_list) – List of substrings of device names of touchpads to be managed. The entries in the specified list should be only substrings of devices listed as Virtual core pointer, not of devices listed as Virtual core keyboard.
  • touchpad_states (dict) – Dictionary mapping a rotation state (normal, inverted, left, right) to either enabled or disabled, depending on whether the touchpads shall be enabled or disabled if the output is currently in the corresponding state.
  • rotation_hook (string) – A string to be run by a shell after a rotation that changes the screen ratio (e.g. from normal to left). It will be executed after the rotation takes place, but before the inputs are mapped to the output and before the bar resizes itself.
  • additional_controls ((string,string_list)_list) – A list of (contents, highlight_groups) pairs. For each entry, an additional segment with the given contents and highlight groups is omitted. These segments obtain the same click values and may also be used to control the segment behavior. Also, all segments additionally use the srot highlight group and the contents may be a format string with all fields (except icon) available.
  • hide_controls (bool) – Hide the extra control segments. They may be shown via segment interaction.

Highlight groups used: srot:normal or srot:inverted or srot:right or srot:left or srot:rotation or srot (if the name parameter is rotation) or srot:auto or srot:locked or srot:mode or srot (if the name parameter is mode) or None (if the name is set to something else).

Click values supplied: mode (string), rotation (string), output (string, the output this segment is rendered to), managed_output (string, the screen currently managed), touch_output (string, the screen where touch inputs are mapped to).

Interaction: This segment supports interaction via bar commands in the following way. (Note that parameters given to the bar may be combined with click values.)

Bar command Description
#bar;pass_oneshot:capture_input:<output> Map all specified input devices to <output> (experimental)
#bar;pass_oneshot:capture:<output> Rotate the screen <output> instead (experimental)
#bar;pass_oneshot:toggle_rot Toggle auto rotation if used on the screen that is currently managed; otherwise ignored.
#bar;pass_oneshot:toggle_controls:<outpt> Toggles the visibility of additional control segments on output <output>