~fnux/monitor-handler

ref: a85cadaa9df3162e5fc4496801a2fcb024f57010 monitor-handler/monitor-event-handler.sh -rwxr-xr-x 571 bytes View raw
a85cadaa — Timothée Floure Initial commit: event listener and simple handler 1 year, 10 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

if [ "$#" -lt 4 ]; then
  echo "Missing arguments !"
  exit 1
fi

while [ "$#" -gt 0 ]; do
  case "$1" in
    --output) output="$2"; shift 2;;
    --action) action="$2"; shift 2;;
    *) echo "Unknown parameter passed: $1"; exit 1;;
  esac
done

echo "Marching: $action $output"
case "$output $action" in
  "DP-1 connect")
    xrandr --output DP-1 --mode 2560x1080 --pos 1920x0 --rotate normal
    nitrogen --restore
    ;;
  "DP-1 disconnect")
    xrandr --output DP-1 --off
    nitrogen --restore
    ;;
  *)
    echo "-> Unknown combination."
    ;;
esac