Initial Commit
This commit is contained in:
commit
8d205aa7f8
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
set -euf
|
||||
|
||||
BACKLIGHT_PATH="${BACKLIGHT_PATH:-/sys/class/backlight/amdgpu_bl0/brightness}"
|
||||
|
||||
errecho() {
|
||||
>&2 printf '%s\n' "$*"
|
||||
}
|
||||
|
||||
usage() {
|
||||
errecho "\
|
||||
Usage: ${0##*/} [-hq] [-s VALUE] [-c VALUE]
|
||||
No arguments: Print current brightness and exit
|
||||
If -s and -c are specified, -c takes priority
|
||||
|
||||
-h show this help
|
||||
-q print current brightness to stdout and exit
|
||||
-s <VALUE> set brightness to VALUE
|
||||
-c <VALUE> change brightness by VALUE"
|
||||
exit 0
|
||||
}
|
||||
|
||||
q=
|
||||
nb=
|
||||
cb="$(cat "$BACKLIGHT_PATH")"
|
||||
while getopts :hqs:c: OPT; do
|
||||
case $OPT in
|
||||
h) usage ;;
|
||||
q) q=1 ;;
|
||||
s) nb=$OPTARG ;;
|
||||
c) nb=$((cb + OPTARG)) ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
done
|
||||
[ $q ] && echo "$cb" && exit 0
|
||||
errecho "Current brightness: $cb"
|
||||
|
||||
[ -z "$nb" ] && errecho "Brightness not changed" && exit 0
|
||||
[ "$nb" -gt 255 ] && nb=255
|
||||
[ "$nb" -lt 0 ] && nb=0
|
||||
|
||||
printf '%s' "$nb" > "$BACKLIGHT_PATH" && errecho "New brightness: $nb" || errecho "Error setting brightness!"
|
|
@ -0,0 +1,29 @@
|
|||
# backlightctl
|
||||
A simple script to change the backlight brightness value on laptops. Mostly made as a workaround for [this bug](https://bugzilla.kernel.org/show_bug.cgi?id=203905).
|
||||
|
||||
## Configuration
|
||||
The only configurable variable is the backlight path. It defaults to `/sys/class/backlight/amdgpu_bl0/brightness`. You can change `BACKLIGHT_PATH` to point to the file path.
|
||||
|
||||
## Usage
|
||||
```
|
||||
Usage: backlightctl [-h] [-s VALUE] [-c VALUE]
|
||||
No arguments: Print current brightness and exit
|
||||
If -s and -c are specified, -c takes priority
|
||||
|
||||
-h show this help
|
||||
-q print current brightness to stdout and exit
|
||||
-s <VALUE> set brightness to VALUE
|
||||
-c <VALUE> change brightness by VALUE
|
||||
```
|
||||
|
||||
## Recommendations
|
||||
- Move this script to `/usr/local/bin`
|
||||
- If your backlight isn't saved on reboot, add the following to `/etc/rc.local`:
|
||||
```
|
||||
/usr/local/bin/backlightctl -s <your_preferred_brightness>
|
||||
```
|
||||
- (doas) add the following to `/etc/doas.conf`:
|
||||
- I don't know the equivalent sudo rule for this
|
||||
```
|
||||
permit nopass :wheel as root cmd backlightctl
|
||||
```
|
Loading…
Reference in New Issue