diff options
Diffstat (limited to '')
-rwxr-xr-x | pkgs/by-name/br/brightness/brightness.sh | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/pkgs/by-name/br/brightness/brightness.sh b/pkgs/by-name/br/brightness/brightness.sh index 887dbb1e..f38bb5a5 100755 --- a/pkgs/by-name/br/brightness/brightness.sh +++ b/pkgs/by-name/br/brightness/brightness.sh @@ -1,24 +1,33 @@ -#!/usr/bin/env dash - -# shellcheck source=/dev/null -SHELL_LIBRARY_VERSION="2.1.2" . %SHELL_LIBRARY_PATH +#!/usr/bin/env sh + +# nixos-config - My current NixOS configuration +# +# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of my nixos-config. +# +# You should have received a copy of the License along with this program. +# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. + +die() { + echo "ERROR: $1" + exit 1 +} help() { cat <<EOF This is a system brightness manager USAGE: - $NAME up [VALUE] | down [VALUE] + $NAME set VALUE OPTIONS: --help | -h Output this help and exit. - --version | -v - Output the version and exit. - COMMANDS: - set [VALUE] + set VALUE Set the brightness to the specified percentage. ARGUMENTS: @@ -27,17 +36,14 @@ ARGUMENTS: EOF } -BACKLIGHT="/sys/class/backlight/%BACKLIGHT_NAME" +BACKLIGHT="/sys/class/backlight/$BACKLIGHT_NAME" brightness() { perc="$1" - max="$(cat $BACKLIGHT/max_brightness)" - + max="$(cat "$BACKLIGHT/max_brightness")" new="$(echo | awk --assign=perc="$perc" '{printf (perc / 100)}')" - output="$(echo | awk --assign=new="$new" --assign=max="$max" '{printf max * new}')" - echo "$output" >"$BACKLIGHT/brightness" } @@ -47,10 +53,6 @@ for arg in "$@"; do help exit 0 ;; - "--version" | "-v") - version - exit 0 - ;; esac done |