dotfiles/config/i3/backlight.fish

25 lines
618 B
Fish
Raw Normal View History

2018-11-26 09:38:46 +00:00
#!/usr/bin/fish
2020-03-04 15:56:12 +00:00
if pidof ddcutil
exit 1
end
2018-11-26 09:38:46 +00:00
2019-02-18 16:38:21 +00:00
set brightness (cat /sys/class/backlight/intel_backlight/brightness)
2020-03-04 12:27:36 +00:00
set bar (seq -s "─" 0 (math $brightness / 42) | tr -d '[:digit:]')
2018-11-26 09:38:46 +00:00
2020-03-04 12:27:36 +00:00
set percentage (printf '%16s%d%%' '' (math $brightness / 12))
2018-11-26 09:38:46 +00:00
set body "$percentage\n $bar"
2020-03-04 12:27:36 +00:00
set title ' Helderheid'
2018-11-26 09:38:46 +00:00
set file /tmp/notify-brightness.id
2020-03-04 12:27:36 +00:00
set age (find "$file" -cmin -0,025)
2018-11-26 09:38:46 +00:00
if [ -n "$age" ]
2020-03-04 12:27:36 +00:00
notify-send.sh -r (cat "$file") -t 1500 "$title" "$body"
2018-11-26 09:38:46 +00:00
touch "$file"
else
2020-03-04 12:27:36 +00:00
set id (notify-send.sh -p -t 1500 "$title" "$body")
2018-11-26 09:38:46 +00:00
echo $id > "$file"
chmod 600 "$file"
end
2020-03-04 15:56:12 +00:00
ddcutil setvcp 10 $brightness