dotfiles/config/i3/backlight.fish

24 lines
618 B
Fish
Executable file

#!/usr/bin/fish
if pidof ddcutil
exit 1
end
set brightness (cat /sys/class/backlight/intel_backlight/brightness)
set bar (seq -s "─" 0 (math $brightness / 42) | tr -d '[:digit:]')
set percentage (printf '%16s%d%%' '' (math $brightness / 12))
set body "$percentage\n $bar"
set title ' Helderheid'
set file /tmp/notify-brightness.id
set age (find "$file" -cmin -0,025)
if [ -n "$age" ]
notify-send.sh -r (cat "$file") -t 1500 "$title" "$body"
touch "$file"
else
set id (notify-send.sh -p -t 1500 "$title" "$body")
echo $id > "$file"
chmod 600 "$file"
end
ddcutil setvcp 10 $brightness