14 lines
364 B
Nix
14 lines
364 B
Nix
self:
|
|
with self; ''
|
|
status=$(cat /sys/class/power_supply/BAT0/status)
|
|
if [ $status != "Discharging" ]; then
|
|
exit 0
|
|
fi
|
|
|
|
capacity=$(cat /sys/class/power_supply/BAT0/capacity)
|
|
if [ $capacity -lt 20 ]; then
|
|
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus
|
|
${libnotify}/bin/notify-send -u critical "Battery ''${capacity}%"
|
|
fi
|
|
''
|