diff options
| author | Inqiyad Sabr <sabr@ariamath.xyz> | 2025-10-28 15:29:20 +0600 |
|---|---|---|
| committer | Inqiyad Sabr <sabr@ariamath.xyz> | 2025-10-28 15:29:20 +0600 |
| commit | a0f358d43f7ed0601dab4335ff84b5a884d1ecb7 (patch) | |
| tree | 23e8063a24ed1b577f01c69149c0aecf6ca76167 | |
| parent | cb888d0a905179ea25e5b860b1a1a31f8de64e13 (diff) | |
Fixed sbc NULL arithmetic on set increase and decrease options
| -rw-r--r-- | README.md | 4 | ||||
| -rwxr-xr-x | sbc | 60 |
2 files changed, 34 insertions, 30 deletions
@@ -1,4 +1,4 @@ -# brightnessctl +# Simple Brightness Control A simple tool to increase decrease and set brightness, infact that's all it does ;-) # License @@ -9,4 +9,4 @@ To install this you just need to put this script in one of your preferred `${PAT (or maybe I'll just add a `./install` file) # Usage -See `brl -h` for more information. +See `sbc -h` for more information. @@ -1,34 +1,38 @@ #!/bin/sh -# ==================================== -# Program : brl (brightness control) +# ================================== # License : The Unlicense # Author : sabr@ariamath.xyz # Version : 0.0.1 -# ==================================== +# ================================== # Honestly, brightnessctl is bloat. -# ==================================== +# ================================== device="$(find /sys/class/backlight/*)" -fmax="${device}/max_brightness" -fnow="${device}/brightness" -m="$(cat "${fmax}")" -c="$(cat "${fnow}")" -v=$2 -case "$1" in - "-s") printf "%d" $((v * m / 100)) > "${fnow}";; - "-i") printf "%d" $((c + v * m / 100)) > "${fnow}";; - "-d") printf "%d" $((c - v * m / 100)) > "${fnow}";; - "-v") - printf "brl v0.0.1\n" - printf "A simple brightness control program\n" - ;; - "-h") - printf "brl [options] [value]\n" - printf " -s set brightness %%\n" - printf " -i increase brightness %%\n" - printf " -d decrease brightness %%\n" - ;; - *) - printf "Current brightness: %d%% (%d)\n"\ - $((c * 100 / m)) "$c" - ;; -esac +fmax="$device/max_brightness" +fnow="$device/brightness" +m="$(cat "$fmax")" +c="$(cat "$fnow")" +if [ $# -gt 1 ]; +then + case "$1" in + "-s") printf "%d" $(($2 * m / 100)) > "$fnow";; + "-i") printf "%d" $((c + $2 * m / 100)) > "$fnow";; + "-d") printf "%d" $((c - $2 * m / 100)) > "$fnow";; + esac +else + case "$1" in + "-v") + printf "brl v0.0.1\n" + printf "A simple brightness control program\n" + ;; + "-h") + printf "brl [options] [value]\n" + printf " -s set brightness %%\n" + printf " -i increase brightness %%\n" + printf " -d decrease brightness %%\n" + ;; + *) + printf "Current brightness: %d%% (%d)\n"\ + $((c * 100 / m)) "$c" + ;; + esac +fi |