Experiment scaling via launch of mate-settings-daemon
[khome.git] / home / bin / monitor-brightness
CommitLineData
ba943891
SK
1#! /bin/bash
2
3f43e4e0
SK
3max() {
4 if [[ "$1" -gt "$2" ]]; then echo "$1"; else echo "$2"; fi
5}
6
7min() {
8 if [[ "$1" -lt "$2" ]]; then echo "$1"; else echo "$2"; fi
9}
10
ba943891
SK
11_get() {
12 sudo ddcutil getvcp 10 | grep -o ' current value = \+[0-9]\+' | awk '{print $4}'
13}
14
15_set() {
16 sudo ddcutil setvcp 10 "$1"
17}
18
880ba5be 19args="$*"
ba943891 20
880ba5be 21case "$args" in
ba943891 22 '') _get;;
3f43e4e0
SK
23 i | inc | increase) _set "$(min $(( $(_get) + 5)) 100)";;
24 d | dec | decrease) _set "$(max $(( $(_get) - 5)) 0)";;
880ba5be
SK
25 *)
26 if [[ "$args" =~ ^[0-9]+$ && "$args" -gt -1 && "$args" -lt 101 ]]; then
27 _set "$args"
28 else
29 printf 'Error: expected a numeric argument between 0 and 100, but given "%s"\n' "$args" >&2
30 exit 1
31 fi
ba943891 32esac
This page took 0.040969 seconds and 4 git commands to generate.