diff options
Diffstat (limited to '.config/swayrbar/scripts/brightness-status')
-rwxr-xr-x | .config/swayrbar/scripts/brightness-status | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/.config/swayrbar/scripts/brightness-status b/.config/swayrbar/scripts/brightness-status new file mode 100755 index 0000000..562ee62 --- /dev/null +++ b/.config/swayrbar/scripts/brightness-status @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +brightness_path=/sys/class/backlight/*/brightness +brightness_max_path=/sys/class/backlight/*/max_brightness + +if [ -f "${brightness_path}" ] +then + brightness="$(cat $brightness_path)" +fi + +if [ -f "${brightness_max_path}" ] +then + brightness_max="$(cat /sys/class/backlight/*/max_brightness)" +fi + +if [ -n "${brightness}" ] && [ -n "${brightness_max}" ] +then + level=$(echo "scale=2; $brightness / $brightness_max * 100" | bc) + + printf " " + printf "%.0f\n" $level +fi + |