aboutsummaryrefslogtreecommitdiff
path: root/util/backlight.sh
blob: 15a842339993f1c24ed77924184e7c491875259d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
set -x
set -e
# Note the trailing slash
# base="/sys/class/backlight/amdgpu_bl0/"
base="/sys/class/backlight/intel_backlight/"

percent="$1"; shift
_backlight="${base}brightness"
_max="${base}max_brightness"

# Since `bc` is often not installed by default, just use awk
_max="$(awk '{print $1/100;}' "$_max")"
percent="$(echo "${percent}" | awk '{print int($1*'"$_max"');}')"

echo $percent


sudo sh -c "echo \"$percent\" > $_backlight"