portable/check-battery: add DBUS env to fix notifications

This commit is contained in:
Benjamin Yule Bädorf 2024-03-29 14:12:52 +01:00
parent cb4c54ce38
commit b3ff15b0a4
Signed by: b12f
GPG key ID: 729956E1124F8F26
2 changed files with 2 additions and 1 deletions

View file

@ -3,7 +3,7 @@
services.cron = { services.cron = {
enable = true; enable = true;
systemCronJobs = [ systemCronJobs = [
"*/5 * * * * root ${pkgs.check-battery}/bin/check-battery" "*/5 * * * * b12f ${pkgs.check-battery}/bin/check-battery"
]; ];
}; };
} }

View file

@ -7,6 +7,7 @@ fi
capacity=$(cat /sys/class/power_supply/BAT0/capacity) capacity=$(cat /sys/class/power_supply/BAT0/capacity)
if [ $capacity -lt 20 ]; then 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}%" ${libnotify}/bin/notify-send -u critical "Battery ''${capacity}%"
fi fi
'' ''