Move today's goals/tasks to the top of the daily template
[khome.git] / home / bin / monitor-brightness
1 #! /bin/bash
2
3 max() {
4 if [[ "$1" -gt "$2" ]]; then echo "$1"; else echo "$2"; fi
5 }
6
7 min() {
8 if [[ "$1" -lt "$2" ]]; then echo "$1"; else echo "$2"; fi
9 }
10
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
19 args="$*"
20
21 case "$args" in
22 '') _get;;
23 i | inc | increase) _set "$(min $(( $(_get) + 5)) 100)";;
24 d | dec | decrease) _set "$(max $(( $(_get) - 5)) 0)";;
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
32 esac
This page took 0.083195 seconds and 4 git commands to generate.