summaryrefslogtreecommitdiffstats
path: root/bin/bright
diff options
context:
space:
mode:
Diffstat (limited to 'bin/bright')
-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))