From 7b202de6cc4a5e353c788be8ca88fd831c81ace1 Mon Sep 17 00:00:00 2001 From: ange Date: Sat, 18 May 2024 22:15:56 +0200 Subject: [PATCH] feat: cleaner light/vol rounds --- .config/nvim/pack/plugins/opt/telescope | 2 +- .config/nvim/pack/plugins/opt/treesitter | 2 +- .config/suckless/update.sh | 2 +- .local/bin/light | 17 ++++------------- .local/bin/vol | 2 +- 5 files changed, 8 insertions(+), 17 deletions(-) diff --git a/.config/nvim/pack/plugins/opt/telescope b/.config/nvim/pack/plugins/opt/telescope index 52f5001..0c12735 160000 --- a/.config/nvim/pack/plugins/opt/telescope +++ b/.config/nvim/pack/plugins/opt/telescope @@ -1 +1 @@ -Subproject commit 52f500110bcf9190b44b4d8640162adc86772ec4 +Subproject commit 0c12735d5aff6a48ffd8111bf144dc2ff44e5975 diff --git a/.config/nvim/pack/plugins/opt/treesitter b/.config/nvim/pack/plugins/opt/treesitter index 8012b55..1eabe69 160000 --- a/.config/nvim/pack/plugins/opt/treesitter +++ b/.config/nvim/pack/plugins/opt/treesitter @@ -1 +1 @@ -Subproject commit 8012b55eee65eba1d1ee4df0a186d30e72dcbe65 +Subproject commit 1eabe69bfa8f78e14fcf5d42a2b3881babaca30a diff --git a/.config/suckless/update.sh b/.config/suckless/update.sh index a2e4157..44fade5 100755 --- a/.config/suckless/update.sh +++ b/.config/suckless/update.sh @@ -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 diff --git a/.local/bin/light b/.local/bin/light index c5851dc..1ed1680 100755 --- a/.local/bin/light +++ b/.local/bin/light @@ -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 diff --git a/.local/bin/vol b/.local/bin/vol index e0fe5a0..cfa9b32 100755 --- a/.local/bin/vol +++ b/.local/bin/vol @@ -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