Battery alert script added for laptops. Provides both speech and sound alerts.

This commit is contained in:
Storm Dragon 2023-10-11 19:39:26 -04:00
parent aae01bff20
commit 9b539d48ab
2 changed files with 26 additions and 0 deletions

1
i38.sh
View File

@ -637,6 +637,7 @@ if command -v remind &> /dev/null && command -v notify-send &> /dev/null ; then
echo "exec_always --no-startup-id $(command -v remind) -z '-k:${HOME}/.config/i3/scripts/reminder.sh %s &' ${HOME}/.reminders < /dev/null > /dev/null 2>&1" echo "exec_always --no-startup-id $(command -v remind) -z '-k:${HOME}/.config/i3/scripts/reminder.sh %s &' ${HOME}/.reminders < /dev/null > /dev/null 2>&1"
touch ~/.reminders touch ~/.reminders
fi fi
exec_always --no-startup-id ${i3Path}/scripts/sound.py
if [[ $dex -eq 0 ]]; then if [[ $dex -eq 0 ]]; then
echo '# Start XDG autostart .desktop files using dex. See also' echo '# Start XDG autostart .desktop files using dex. See also'
echo '# https://wiki.archlinux.org/index.php/XDG_Autostart' echo '# https://wiki.archlinux.org/index.php/XDG_Autostart'

25
scripts/battery_alert.sh Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
if ! command -v acpi &> /dev/null ; then
exit 0
fi
while : ; do
acpi -b | awk -F'[,:%]' '{print $2, $3}' | {
read -r status capacity
if [[ "$status" == "Discharging" ]] && [[ "$capacity" -le 15 ]] && [[ "$capacity" -gt 10 ]]; then
play -qV0 "|sox -n -p synth saw E2 fade 0 0.25 0.05" "|sox -n -p synth saw E2 fade 0 0.25 0.05" norm -7
spd-say -P important "Battery $capacity percent."
elif [[ "$status" == "Discharging" ]] && [[ "$capacity" -le 10 ]] && [[ "$capacity" -gt 5 ]]; then
play -qV0 "|sox -n -p synth saw E2 fade 0 0.25 0.05" "|sox -n -p synth saw E2 fade 0 0.25 0.05" norm -7
spd-say -P important "Battery $capacity percent."
elif [[ "$status" == "Discharging" ]] && [[ "$capacity" -lt 5 ]]; then
play -qV0 "|sox -np synth sq C#5 sq D#5 sq F#5 sq A5 sq C#6" remix - fade 0 5.5 5 pitch -400
spd-say -P important "Battery $capacity percent."
fi
}
sleep 5m
done
exit 0