/xrr-events

XRandR event notification daemon

Primary LanguageC++GNU General Public License v2.0GPL-2.0

About:

xrr-events provides a way to run an executable whenever an output is added, removed, or modified (for example, when the resolution changes). It's meant to be run as a user-level daemon.

Usage:

`xrr-events --daemonize` will start the process and fork into the background. `xrr-events --help` will list all available options.
View the manpage for further details.

Example event-handler script:

#!/bin/bash

if [ $# -lt 3 ]; then
    echo "Wrong number of args: $#"
    exit -1
fi

#the output name (eg: HDMI1, LVDS1, etc)
output_name="$1"
#either Connected or Disconnected
connection_state="$2"
#resolution as a string (eg: 1366x768), or None if output isn't currently enabled
mode_name="$3"

if [ ${output_name} != "HDMI1" ]; then
    echo "Ignoring output: ${output_name}"
    exit 0
fi

if [ ${connection_state} = "Connected" -a ${mode_name} == "None" ]; then
    echo "Turning on output"
    xrandr --output HDMI1 --auto --right-of LVDS1
    #to set wallpaper for screen 2
    nitrogen --restore
elif [ ${connection_state} = "Disconnected" -a ${mode_name} != "None" ]; then
    echo "Turning off output"
    xrandr --output HDMI1 --off
fi