blob: a0d61768d4609b34006dc4ae0d206f851cd383d6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#!/bin/sh
set -e
set -x
# Note the trailing slash
base="/sys/class/backlight/amdgpu_bl0/"
# base="/sys/class/backlight/intel_backlight/"
# pinebook
# base="/sys/class/backlight/backlight/"
_backlight="${base}brightness"
_max="${base}max_brightness"
_max="$(awk '{print $1/100;}' < "$_max")"
percent="$(echo "$1" | awk '{print int($1*'"$_max"');}')"
if ! [ -w "$_backlight" ] ; then
sudo chgrp "$(id -g)" "$_backlight"
sudo chmod g+w "$_backlight"
fi
sh -c "echo \"$percent\" > $_backlight"
## If you want to do this withotu a password:
# %wheel ALL=(ALL) NOPASSWD: /usr/bin/chgrp 1001 /sys/class/backlight/amdgpu_bl0/brightness
# %wheel ALL=(ALL) NOPASSWD: /usr/bin/chmod g+w /sys/class/backlight/amdgpu_bl0/brightness
# %wheel ALL=(ALL) NOPASSWD: /usr/bin/chgrp 1001 /sys/class/backlight/intel_backlight/brightness
# %wheel ALL=(ALL) NOPASSWD: /usr/bin/chmod g+w /sys/class/backlight/intel_backlight/brightness
|