feat: cleaner light/vol rounds

This commit is contained in:
ange 2024-05-18 22:15:56 +02:00
parent 202436aafa
commit 7b202de6cc
Signed by: ange
GPG Key ID: 9E0C4157BB7BEB1D
5 changed files with 8 additions and 17 deletions

@ -1 +1 @@
Subproject commit 52f500110bcf9190b44b4d8640162adc86772ec4
Subproject commit 0c12735d5aff6a48ffd8111bf144dc2ff44e5975

@ -1 +1 @@
Subproject commit 8012b55eee65eba1d1ee4df0a186d30e72dcbe65
Subproject commit 1eabe69bfa8f78e14fcf5d42a2b3881babaca30a

View File

@ -4,5 +4,5 @@ set -e
cd "$(dirname "$0")"
for d in */; do
(cd "$d" && sudo make clean install)
(cd "$d" && make clean install)
done

View File

@ -1,17 +1,5 @@
#!/bin/bash -e
function round() {
local nb="$1"
local closest="${2#-}"
local mod; mod="$((nb % closest))"
if [ "$mod" -lt "$((closest / 2))" ]; then
echo "$((nb - mod))"
else
echo "$((nb + closest - mod))"
fi
}
function get_current() {
local cur; cur="$(cat "$1/brightness")"
local max; max="$(cat "$1/max_brightness")"
@ -30,11 +18,14 @@ NOTIFY=(notify-send -t 1000 -a "$(basename "$0")" -u low)
DIRS=(/sys/class/backlight/*)
CUR="$(get_current "${DIRS[0]}")"
echo "$CUR"
echo "\$(($CUR + $1 - $CUR % $1 + $CUR % $1 / $1 * $1))"
case "${1:0:1}" in
'') echo "$CUR"; exit ;;
'+'|'-') CUR="$(round $((CUR + $1)) "$1")" ;;
'+'|'-') CUR="$(($CUR + $1 - $CUR % $1 + $CUR % $1 * 10 / $1 / 5 * $1))" ;;
*) CUR="$1" ;;
esac
echo "$CUR"
[ "$CUR" -lt 0 ] && CUR=0
[ "$CUR" -gt 100 ] && CUR=100

View File

@ -5,7 +5,7 @@ NOTIFY=(notify-send -t 1000 -a "$(basename "$0")" -u low)
function update_vol() {
if [[ "$1" =~ ^(-|\+)* ]]; then
CUR="$((CUR - CUR % $1 + $1))"
CUR="$(($CUR + $1 - $CUR % $1 + $CUR % $1 * 10 / $1 / 5 * $1))"
[ "$CUR" -lt 0 ] && CUR=0
[ "$CUR" -gt 150 ] && CUR=150
else