mirror of
https://github.com/tomasriveral/nixos.git
synced 2026-08-12 02:28:37 +02:00
Formated with alejandra
This commit is contained in:
@@ -1,48 +1,48 @@
|
||||
# taken and adapted https://github.com/miniMinn24/Battery_Notify with MIT License
|
||||
{
|
||||
writeShellApplication,
|
||||
mplayer,
|
||||
brightnessctl,
|
||||
...
|
||||
writeShellApplication,
|
||||
mplayer,
|
||||
brightnessctl,
|
||||
...
|
||||
}: let
|
||||
NotifySound = ../../assets/battery_notify.mp3;
|
||||
NotifySound = ../../assets/battery_notify.mp3;
|
||||
in
|
||||
writeShellApplication {
|
||||
name = "custom-batterywarning";
|
||||
runtimeInputs = [
|
||||
mplayer
|
||||
brightnessctl
|
||||
];
|
||||
text = ''
|
||||
writeShellApplication {
|
||||
name = "custom-batterywarning";
|
||||
runtimeInputs = [
|
||||
mplayer
|
||||
brightnessctl
|
||||
];
|
||||
text = ''
|
||||
|
||||
# Delay for startup
|
||||
sleep 5
|
||||
# Delay for startup
|
||||
sleep 5
|
||||
|
||||
|
||||
playsound() {
|
||||
mplayer ${NotifySound}
|
||||
}
|
||||
playsound() {
|
||||
mplayer ${NotifySound}
|
||||
}
|
||||
|
||||
|
||||
|
||||
while true; do
|
||||
Battery_Status="$(cat /sys/class/power_supply/BAT*/status)"
|
||||
Battery_Capacity="$(cat /sys/class/power_supply/BAT*/capacity)"
|
||||
while true; do
|
||||
Battery_Status="$(cat /sys/class/power_supply/BAT*/status)"
|
||||
Battery_Capacity="$(cat /sys/class/power_supply/BAT*/capacity)"
|
||||
|
||||
if [ "$Battery_Status" == "Discharging" ]; then
|
||||
if [ "$Battery_Capacity" -le 20 ] && [ "$Battery_Capacity" -ge 10 ]; then
|
||||
notify-send -e -u critical "Battery Low!" "Power running out: <b>''${Battery_Capacity}%</b>"
|
||||
playsound
|
||||
sleep 180
|
||||
if [ "$Battery_Status" == "Discharging" ]; then
|
||||
if [ "$Battery_Capacity" -le 20 ] && [ "$Battery_Capacity" -ge 10 ]; then
|
||||
notify-send -e -u critical "Battery Low!" "Power running out: <b>''${Battery_Capacity}%</b>"
|
||||
playsound
|
||||
sleep 180
|
||||
|
||||
elif [ "$Battery_Capacity" -lt 10 ]; then
|
||||
notify-send -e -u critical "Battery Low!" "<b>Save your works</b> before immediate shutdown."
|
||||
playsound
|
||||
sleep 180
|
||||
fi
|
||||
else
|
||||
sleep 120
|
||||
fi
|
||||
done
|
||||
'';
|
||||
}
|
||||
elif [ "$Battery_Capacity" -lt 10 ]; then
|
||||
notify-send -e -u critical "Battery Low!" "<b>Save your works</b> before immediate shutdown."
|
||||
playsound
|
||||
sleep 180
|
||||
fi
|
||||
else
|
||||
sleep 120
|
||||
fi
|
||||
done
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user