Skip to content

Commit

Permalink
make brightness work with amdgpu
Browse files Browse the repository at this point in the history
  • Loading branch information
anlutro committed Apr 12, 2024
1 parent 3e2fa39 commit d52af1d
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions configs/i3/block-scripts/brightness.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
#!/bin/sh

dir=/sys/class/backlight/intel_backlight
[ -e "$dir" ] || exit 1
cur=$(cat $dir/actual_brightness)
max=$(cat $dir/max_brightness)
pct=$(echo "$cur / $max * 100" | bc -l)
for try_dir in intel_backlight amdgpu_bl0; do
if [ -e "/sys/class/backlight/$try_dir" ]; then
dir="/sys/class/backlight/$try_dir"
break
fi
done
if [ -z "$dir" ]; then exit 1; fi

cur="$(cat "$dir/actual_brightness")"
max="$(cat "$dir/max_brightness")"
pct="$(echo "$cur / $max * 100" | bc -l)"
if echo "$pct" | grep -qP '^0?.0\d+$'; then
pct=0.1
pct=0.1
fi
printf "Brightness %.1f%%\n" $pct
printf "Brightness %.1f%%\n" $pct
Expand Down

0 comments on commit d52af1d

Please sign in to comment.