summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2021-08-22 20:14:10 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2021-08-22 20:14:10 (EDT)
commit510124ec89a356bcc5d2ad28c3adcf7866c62dea (patch)
tree1502f81278eb351fe1f44a0944ff1734e8f4da4a /bin
parent0fb86f66f72b6b3e85f14bb70f258640b1dcdfb3 (diff)
downloadfluxbox-510124ec89a356bcc5d2ad28c3adcf7866c62dea.zip
fluxbox-510124ec89a356bcc5d2ad28c3adcf7866c62dea.tar.gz
fluxbox-510124ec89a356bcc5d2ad28c3adcf7866c62dea.tar.bz2
bin/bright: Don't hardcode parameters
Diffstat (limited to 'bin')
-rwxr-xr-xbin/bright19
1 files changed, 14 insertions, 5 deletions
diff --git a/bin/bright b/bin/bright
index 87126e1..dd8f2df 100755
--- a/bin/bright
+++ b/bin/bright
@@ -2,14 +2,20 @@
set -eu
+STEPS=8
+MIN=2
+max=
+
get_b()
{
local b=
b=$(brightnessctl --class=backlight get) || return 1
printf '%.0f\n' $(printf \
- 'scale = 4; (7 * sqrt((2 - %d) * (%d - 3102))) / 1550\n' \
- ${b} ${b} | bc)
+ 'scale = 4;'$(: \
+ )'((%d - 1) * sqrt((%d - %d) * (%d - (2 * %d - %d)))) / '$(: \
+ )'(%d - %d)\n' \
+ ${STEPS} ${MIN} ${b} ${b} ${max} ${MIN} ${max} ${MIN} | bc)
return 0
}
@@ -19,9 +25,10 @@ set_b()
local b="${1}"
shift 1
- brightnessctl --class=backlight set $(printf '%.0f\n' \
- $(printf 'scale = 4; 2 + (1 - sqrt(1 - (%d / 7)^2)) * 1550\n' \
- ${b} | bc)) || return 1
+ brightnessctl --class=backlight set $(printf '%.0f\n' $(printf \
+ 'scale = 4;'$(: \
+ )'%d + (1 - sqrt(1 - (%d / (%d - 1))^2)) * (%d - %d)\n' \
+ ${MIN} ${b} ${STEPS} ${max} ${MIN} | bc)) || return 1
return 0
}
@@ -53,6 +60,8 @@ main()
;;
esac
+ max=$(brightnessctl --class=backlight max)
+
b=$(get_b) || return 1
: $((b += 1))
: $((b ${dir}= 1))