mirror of
https://github.com/tomasriveral/nixos.git
synced 2026-08-12 02:28:37 +02:00
formated whole config with alejandra
This commit is contained in:
@@ -1,69 +1,73 @@
|
||||
# taken and adapted https://github.com/miniMinn24/Battery_Notify with MIT License
|
||||
{ writeShellApplication, mplayer, brightnessctl, ... }:
|
||||
let
|
||||
{
|
||||
writeShellApplication,
|
||||
mplayer,
|
||||
brightnessctl,
|
||||
...
|
||||
}: let
|
||||
NotifySound = ../../assets/battery_notify.mp3;
|
||||
in
|
||||
writeShellApplication {
|
||||
name = "custom-batterynotify";
|
||||
in
|
||||
writeShellApplication {
|
||||
name = "custom-batterynotify";
|
||||
runtimeInputs = [
|
||||
mplayer
|
||||
brightnessctl
|
||||
];
|
||||
text = ''
|
||||
];
|
||||
text = ''
|
||||
|
||||
# Delay for startup
|
||||
sleep 5
|
||||
# Delay for startup
|
||||
sleep 5
|
||||
|
||||
# Change your sound path here
|
||||
# Change your sound path here
|
||||
|
||||
playsound() {
|
||||
mplayer ${NotifySound}
|
||||
}
|
||||
playsound() {
|
||||
mplayer ${NotifySound}
|
||||
}
|
||||
|
||||
adjustBrightness() {
|
||||
local adjustment="$1"
|
||||
brightnessctl set "$adjustment"
|
||||
}
|
||||
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"
|
||||
}
|
||||
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)
|
||||
# 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
|
||||
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
|
||||
sleep 1
|
||||
done
|
||||
'';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user