diff options
author | Patrick 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) |
commit | 510124ec89a356bcc5d2ad28c3adcf7866c62dea (patch) | |
tree | 1502f81278eb351fe1f44a0944ff1734e8f4da4a /bin | |
parent | 0fb86f66f72b6b3e85f14bb70f258640b1dcdfb3 (diff) | |
download | fluxbox-510124ec89a356bcc5d2ad28c3adcf7866c62dea.zip fluxbox-510124ec89a356bcc5d2ad28c3adcf7866c62dea.tar.gz fluxbox-510124ec89a356bcc5d2ad28c3adcf7866c62dea.tar.bz2 |
bin/bright: Don't hardcode parameters
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bright | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -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)) |