Modules: separated hosts-specific modules in new dir

This commit is contained in:
2026-04-23 12:11:23 +02:00
parent 0f003b3a4f
commit f9fe349c49
19 changed files with 413 additions and 379 deletions
-73
View File
@@ -1,73 +0,0 @@
# taken and adapted https://github.com/miniMinn24/Battery_Notify with MIT License
{
writeShellApplication,
mplayer,
brightnessctl,
...
}: let
NotifySound = ../../assets/battery_notify.mp3;
in
writeShellApplication {
name = "custom-batterynotify";
runtimeInputs = [
mplayer
brightnessctl
];
text = ''
# Delay for startup
sleep 5
# Change your sound path here
playsound() {
mplayer ${NotifySound}
}
adjustBrightness() {
local adjustment="$1"
brightnessctl set "$adjustment"
}
sendNotification() {
local title="$1"
local message="$2"
notify-send -h string:x-canonical-private-synchronous:sys-notify -e -u low "$title" "$message"
}
# Runs full time in background
x=0
while true; do
Battery_Status="$(\cat /sys/class/power_supply/BAT*/status)"
Battery_Capacity=$(\cat /sys/class/power_supply/BAT*/capacity)
case "$Battery_Status" in
"Discharging")
if [ $x -eq 1 ]; then
sendNotification "Discharging" "Remains: <b>''${Battery_Capacity}%</b>"
adjustBrightness "15%-"
playsound
x=0
fi
;;
"Charging")
if [ $x -eq 0 ]; then
sendNotification "Charging" "Current: <b>''${Battery_Capacity}%</b>"
adjustBrightness "15%+"
playsound
x=1
fi
;;
"Full")
if [ $x -eq 0 ]; then
sendNotification "Fully Charged" "Noice: <b>''${Battery_Capacity}%</b>"
playsound
x=1
fi
;;
esac
sleep 1
done
'';
}
-48
View File
@@ -1,48 +0,0 @@
# taken and adapted https://github.com/miniMinn24/Battery_Notify with MIT License
{
writeShellApplication,
mplayer,
brightnessctl,
...
}: let
NotifySound = ../../assets/battery_notify.mp3;
in
writeShellApplication {
name = "custom-batterywarning";
runtimeInputs = [
mplayer
brightnessctl
];
text = ''
# Delay for startup
sleep 5
playsound() {
mplayer ${NotifySound}
}
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
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
'';
}