summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2018-05-19 01:37:01 (EDT)
committer P. J. McDermott <pj@pehjota.net>2018-05-19 02:04:27 (EDT)
commit8df79b320c4855ec563578c4f895c2eb0317489b (patch)
treedae428e49ce6a25d1fe3ccd1a85b54369ea9f7d9 /bin
parent04765d010e3391e6c3a2a1f0f84039a7a41f7a7d (diff)
downloadfluxbox-8df79b320c4855ec563578c4f895c2eb0317489b.zip
fluxbox-8df79b320c4855ec563578c4f895c2eb0317489b.tar.gz
fluxbox-8df79b320c4855ec563578c4f895c2eb0317489b.tar.bz2
bin/bright: New script
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bright80
1 files changed, 80 insertions, 0 deletions
diff --git a/bin/bright b/bin/bright
new file mode 100755
index 0000000..04c83f5
--- /dev/null
+++ b/bin/bright
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+set -eu
+
+get_b()
+{
+ # VCP 10 C 100 100
+ read -r vcp feat c val max <<-EOF
+ $(ddcutil -t getvcp 10)
+ EOF
+
+ printf '%s' ${val}
+ return 0
+}
+
+set_b()
+{
+ local b=${1}
+ shift 1
+
+ ddcutil setvcp 10 ${b}
+
+ return 0
+}
+
+inc_b()
+{
+ local d=${1}
+ shift 1
+ local b=
+
+ b=$(($(get_b) + ${d}))
+ if [ ${b} -gt 100 ]; then
+ b=100
+ elif [ ${b} -lt 0 ]; then
+ b=0
+ fi
+
+ set_b ${b}
+}
+
+usage()
+{
+ printf 'Usage: %s {<direction>|<value>}\n' "${0}"
+ printf '\n'
+ printf 'Where <direction> is any word beginning with (in any case):\n'
+ printf ' * "U" for up\n'
+ printf ' * "D" for down\n'
+ printf 'And <value> is any integer between 0 and 100 inclusive\n'
+
+ return 0
+}
+
+main()
+{
+ local dir=
+
+ if [ ${#} -ne 1 ]; then
+ usage 1>&2
+ return 1
+ fi
+
+ dir="${1}"
+ shift 1
+
+ case "${dir}" in
+ [Uu]*) inc_b 20;;
+ [Dd]*) inc_b -20;;
+ *[!0-9]* | '')
+ usage 1>&2
+ return 1
+ ;;
+ *)
+ set_b ${dir}
+ esac
+
+ return 0
+}
+
+main "${@}"