diff --git a/morning-alarm.sh b/morning-alarm.sh index 77b0132..9812111 100755 --- a/morning-alarm.sh +++ b/morning-alarm.sh @@ -1,50 +1,51 @@ #!/bin/sh # -# Wecker-Steuerungsskript +# Alarm Control Script # -# 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. +# This script controls the alarm on the Android device. +# It turns off Bluetooth, increases the volume, and checks if the alarm has been dismissed. +# After the alarm is dismissed, it plays the alarm sound. -echo "Script ausgeführt um: $(date)" > /data/scripts/morning-alarm.log +echo "Script executed at: $(date)" > /data/scripts/morning-alarm.log -# Funktion zum Ausschalten von Bluetooth +# Function to turn off Bluetooth turn_off_bluetooth() { - svc bluetooth disable + echo "Turning off Bluetooth." + svc bluetooth disable || { echo "Error turning off Bluetooth." ; exit 1; } } -# Funktion zum Erhöhen der Lautstärke +# Function to increase the volume increase_volume() { - cmd media_session volume --set 15 --stream 9 + echo "Increasing volume." + cmd media_session volume --set 15 --stream 9 || { echo "Error increasing volume." ; exit 1; } } -# Funktion zum Überprüfen der Weckerbenachrichtigung +# Function to check the alarm notification check_notification() { - # Führe den dumpsys-befehl innerhalb eines Timeout aus - output=$(dumpsys activity processes | grep "com.urbandroid.sleep/") + # Run the dumpsys command within a timeout + output=$(timeout 5s dumpsys activity processes | grep "com.urbandroid.sleep/") - # Überprüfe, ob das Ergebnis nicht leer ist und den Wecker enthält + # Check if the result is not empty and contains the alarm if [ -n "$output" ] && echo "$output" | grep -q "AlarmKlaxon"; then - date && echo "Wecker noch nicht beendet." + date && echo "Alarm not dismissed yet." else + date && echo "Alarm dismissed." killall mpv - date && echo "Wecker beendet." echo "$output" exit fi } -# Hauptprogramm +# Main program -# Ausschalten von Bluetooth +# Turn off Bluetooth turn_off_bluetooth -# Weckersound abspielen +# Play alarm sound /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 +# Increase volume and check notification while true; do increase_volume check_notification done -