wecker/morning-alarm.sh
Ratatoskr d9dc246bed
Update morning-alarm.sh script
Modify the morning-alarm.sh script to enhance clarity and maintainability. The changes involve updating the path for the mpv command to use '/data/scripts/your-new-morning-alarm.ogg' instead of the previous path '/product/media/audio/alarms/your-new-morning-alarm.ogg'. This adjustment ensures consistency with other script paths and makes it easier to locate the alarm sound file.

Changes made:
- Update the path for the mpv command to '/data/scripts/your-new-morning-alarm.ogg'

This modification simplifies the script and aligns it with the path used in other related scripts, improving overall script coherence.
2024-01-24 16:13:32 +01:00

51 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
#
# Wecker-Steuerungsskript
#
# Dieses Skript steuert den Wecker auf dem Android-Gerät.
# Es schaltet Bluetooth aus, erhöht die Lautstärke und überprüft, ob der Wecker beendet wurde.
# Nach dem Beenden des Weckers wird der Weckersound abgespielt.
echo "Script ausgeführt um: $(date)" > /data/scripts/morning-alarm.log
# Funktion zum Ausschalten von Bluetooth
turn_off_bluetooth() {
svc bluetooth disable
}
# Funktion zum Erhöhen der Lautstärke
increase_volume() {
cmd media_session volume --set 15 --stream 9
}
# Funktion zum Überprüfen der Weckerbenachrichtigung
check_notification() {
# Führe den dumpsys-befehl innerhalb eines Timeout aus
output=$(dumpsys activity processes | grep "com.urbandroid.sleep/")
# Überprüfe, ob das Ergebnis nicht leer ist und den Wecker enthält
if [ -n "$output" ] && echo "$output" | grep -q "AlarmKlaxon"; then
date && echo "Wecker noch nicht beendet."
else
killall mpv
date && echo "Wecker beendet."
echo "$output"
exit
fi
}
# Hauptprogramm
# Ausschalten von Bluetooth
turn_off_bluetooth
# Weckersound abspielen
/data/data/com.termux/files/usr/bin/mpv --replaygain=track --loop=inf /data/scripts/your-new-morning-alarm.ogg &
# Lautstärke erhöhen und Benachrichtigung überprüfen
while true; do
increase_volume
check_notification
done