/arandr-indicator

Quick and simple tray icon menu for changing the monitor layout. A great companion to ARandR tool.

Primary LanguagePython

arandr-indicator

Quick and simple tray icon menu for changing the monitor layout. A great companion to ARandR tool.

Demonstration video on YouTube:

YouTube demonstration

Requirements

TODO: Update these requirements to the latest Python 3.x version. See also TODO.md.

How to use

  1. Run arandr.
  2. Configure the monitor layout the way you like.
  3. Save the layout.
    • ARandR tool will save the layout as a simple one-line shell script that calls xrandr with the appropriate commands. The script will be saved in ~/.screenlayout/.
  4. Magic! All layout scripts from that directory will automatically show up in the menu!

Installation

  1. sudo apt-get install python-appindicator python-gtk2 python-xdg arandr
  2. Download arandr-indicator.py and save it anywhere.
  3. chmod +x arandr-indicator.py to make it executable.
  4. ./arandr-indicator.py to execute it.
  5. Add it to autostart, so it runs whenever you login.

Pre-built packages

How to add icons

To define an icon for any ~/.screenlayout/*.sh script, just add a line containing META:ICON = "icon-name-here" anywhere in the first 512 bytes of the file. The actual requirements are:

  • The line must contain:
    • META:ICON string,
    • followed by optional whitespace (spaces or tabs),
    • followed by = (equals sign),
    • followed by optional whitespace (spaces or tabs),
    • followed by the icon name inside double-quotes.
  • The icon name does not support escapes.
  • The icon name cannot contain the double-quote character.
  • The icon name can be:
    • A standard icon name that is available in your current icon theme.
    • A filename to be found in ~/.screenlayout/.
    • A relative path (will be considered relative to ~/.screenlayout/).
    • A path relative to the user home (i.e. beginning with ~).
    • An absolute path.
  • The line must be in the first 512 bytes of the file.
    • This size has been chosen arbitrarily.
    • Since most scripts in that directory will be very small, this is not an issue.
    • It is a good idea to put this line as the first line (or one of the first lines) after the shebang.

Credits

The need for this tool started with my girlfriend's laptop.

The code organization was inspired by indicator-chars, written by Tobias Schlitt.

Further hints and tips

Since the files in ~/.screenlayout/*.sh are just shell scripts, they can do more than calling xrandr to setup the monitors. They can also configure PulseAudio to redirect audio to the HDMI port. Try the following commands:

  • To set audio output to HDMI: pacmd set-card-profile 0 output:hdmi-stereo+input:analog-stereo
  • To set audio output to analog speakers: pacmd set-card-profile 0 output:analog-stereo+input:analog-stereo
  • To see the available cards and profiles in your system: pacmd list-cads
  • Nice GUI to configure PulseAudio: pavucontrol

Read more: