You are not logged in.
Pages: 1
Hi
I wrote a script for battery notification, but don't know what is better to execute. Systemd or cron?
Here is the script:
#!/bin/sh
# Battery status check
BATTERY_STATUS=$(cat /sys/class/power_supply/BAT1/status)
# Battery capacity check
BATTETY_LEVEL=$(cat /sys/class/power_supply/BAT1/capacity)
# Show notifications
if [$BATTERY_STATUS -eq 'Discharging' && $BATTERY_LEVEL -le 15]; then
notify-send -u critical "Battery critical!" "${BATTERY_LEVEL}%"
paplay /usr/share/sounds/freedesktop/stereo/dialog-warning.oga
elif [$BATTERY_STATUS -eq 'Charging' && $BATTERY_LEVEL -eq 100]; then
notify-send -u critical "Battery full!" "${BATTERY_LEVEL}%"
paplay /usr/share/sounds/freedesktop/stereo/dialog-warning.oga
fiLast edited by iskander9908 (2023-08-19 07:23:12)
Offline
use whatever works best for you.
There are many cron implementations, but none of them are installed by default as the base system uses systemd/Timers instead.
i personally just use systemd timers for that exact reason.
Offline
Pages: 1