The morning-alarm.sh script has been modified with the following changes:
- Added the 'break' statement after killing the mpv process to exit the loop when the alarm is dismissed. This prevents unnecessary iterations and improves script efficiency.
- Commented out the line 'killall /data/data/com.termux/files/usr/bin/mpv' since it seems to be redundant after the 'killall mpv' command. If this line is intended for different use, it may need further clarification or context.
These changes enhance the morning-alarm.sh script by optimizing the loop's termination when the alarm is dismissed, improving script efficiency and preventing unnecessary iterations. The redundant 'killall' line has been commented out for clarification.
The generate_text.sh script has been modified with the following changes:
- Updated the variable name 'markdown_file' to 'html_file' to reflect the change in the file format from Markdown to HTML.
- Modified the HTML structure to create a formatted table for the handout, enhancing readability and presentation.
- Added inline CSS styling to the HTML file to improve the table layout and appearance.
These changes improve the generate_text.sh script by switching from Markdown to HTML for better presentation and readability of the handout. Additionally, the HTML table is now more structured and visually appealing.
The commit also includes the removal of the previous notification-related code, which was commented out and not in use.
The goal is to enhance the script's functionality and improve the presentation of the generated handout in HTML format.
The generate_mp3.sh script has been updated with the following changes:
- Added a comment to specify the directory for MP3 files.
- Implemented a command to open the handout.md file using the 'am start' command.
- The 'am start' command opens the file in VIEW mode with the 'text/plain' MIME type.
- This enhancement provides a convenient way to access the handout.md file directly.
The commit aims to improve the functionality and user experience of the generate_mp3.sh script by enabling easy access to the handout file.
The A72_alarm_getter.sh script has been refactored for improved readability and clarity. Changes include:
- Updated script header with standardized information.
- Changed German comments to English for consistency.
- Improved comments and added explanations for key sections.
- Reorganized code structure for better flow.
- Enhanced variable names for increased understanding.
- Added debug information for 'at' jobs.
- Modified output messages for better user understanding.
- Ensured consistent formatting throughout the script.
- Fixed indentation issues and removed unnecessary spaces.
The commit aims to make the script more maintainable and user-friendly, following best practices for scripting.
Enhancements:
- Adjusted the way the alarm sound is played by introducing a loop to increase volume gradually.
- Utilized a loop to iterate over volume levels from 10 to 100 with increments of 10.
- Replaced the previous mpv command with a loop to control the volume for a smoother alarm experience.
Code Clarity:
- Added comments to clarify the purpose of the loop and volume adjustment.
Note: This modification provides a more gradual increase in volume for the morning alarm, enhancing the user experience.
Enhancements:
- Adjusted the way the alarm sound is played by introducing a loop to increase volume gradually.
- Utilized a loop to iterate over volume levels from 10 to 100 with increments of 10.
- Replaced the previous mpv command with a loop to control the volume for a smoother alarm experience.
Code Clarity:
- Added comments to clarify the purpose of the loop and volume adjustment.
Note: This modification provides a more gradual increase in volume for the morning alarm, enhancing the user experience.
Addition of Markdown File:
- Introduce a Markdown file 'handout.md' to store information in a structured format.
- Markdown file is created with headers, columns, and content for German and Spanish text.
Refactoring and Cleanup:
- Declare 'markdown_file' variable to store the path of the Markdown file.
- Introduce 'all' array to store components like 'date' and 'time'.
- Clear files in 'text_dir' at the beginning to ensure a clean start.
File Transfer and Notification:
- Use 'scp' to transfer files to A72, maintaining the directory structure.
- Enhance the curl command to include the Markdown file as an attachment.
- Set the 'Filename' header for better identification on the server.
- Display the constructed curl command for visibility.
- Execute the curl command to send a high-priority notification with the Markdown file.
Logging and Output:
- Display the content of the generated Markdown file.
- Initiate 'generate_mp3.sh' on A72 in the background.
Note: Adjusted the output formatting for better readability in the commit message.
In this commit, I made several improvements to the 'generate_mp3.sh' script:
1. Removed old complete files before processing to ensure a clean slate.
2. Modified the 'create_mp3_files' function to use '>>' instead of '>' when appending text to the complete files.
3. Updated the comments in the script for better clarity.
These changes help maintain a more organized and reliable MP3 generation process. The script now properly appends text to the 'de_complete.txt' and 'es_complete.txt' files, and it removes old complete files before starting the processing.
File Changes:
- Modified 'generate_mp3.sh' (see diff for details)
Note: Please review and test the changes to ensure they meet your requirements.
- Commented out 'set -e' and 'set -x' to prevent stopping the script on errors and disable debugging by default.
- Introduced functions set_brightness, set_colortemp, and set_color for better code organization.
- Modified brightness and color temperature commands to use the new functions.
- Author: Michael Haider
- Created on: 26.01.2024
- Description: This script generates various text files with information such as date, time, news, and weather in German and Spanish.
- The script includes functions to check the IP address of Lisa's iPhone, generate text files in German and Spanish, transfer files to the A72 device, and start generate_mp3.sh on the A72.
- The generated texts are outputted in both German and Spanish.
Added generate_mp3.sh script:
- Author: Michael Haider
- Created on: 26.01.2024
- Description: This script generates MP3 files from text files in German and Spanish using gtts-cli (Google Text-to-Speech).
- The script exports the path to the programs, defines language and category order, sets directories, and includes a function to create MP3 files.
- The generated MP3 files are created with gtts-cli in German or Spanish slow mode based on the file content.
- The script then sets the media volume and loops through categories and languages to play the generated MP3 files at normal or half speed, based on the language indication.
Made the following changes to the wecker.sh script:
- Adjusted comments and translated the comments and script messages into English for better clarity.
- Introduced error handling for SSH commands, Bluetooth operations, and volume adjustments to ensure the script exits gracefully in case of failures.
- Updated variable names for consistency and improved overall readability of the script.
- Removed unnecessary debug-related code and streamlined the script structure.
- Addressed formatting issues for better code presentation.
Adjusted comments and translated the comments and script messages into English for better clarity. The script now provides more informative output during its execution, including status messages for Bluetooth operations, volume adjustment, and alarm notification checks. Additionally, introduced error handling for Bluetooth and volume adjustment operations to ensure the script exits gracefully in case of failures.
The main program section and function names have been retained for continuity, but the script's overall readability and understandability have been improved through language translation and comments rephrasing.
Corrected the path for the 'weckzeit_datei' variable in A72_alarm_getter.sh script. The original path was pointing to '/root/iobroker_scripts/generel/.weckzeiten.txt' and has been updated to the correct path '/root/iobroker_scripts/general/.weckzeiten.txt'.
This ensures that the script can accurately locate and utilize the 'weckzeit_datei' file, preventing potential issues related to the incorrect file path.
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.
Adjust the SSH command in the wecker.sh script for better readability and functionality. Instead of 'cmd media_session volume --set 5 --stream 9', use the more descriptive 'cmd media_session volume scripts/--set 5 --stream 9'. Additionally, update the path for the mpv command to use '/data/scripts/your-new-morning-alarm.ogg'. This change ensures consistency and clarity in the script.
Changes made:
- Replace 'cmd media_session volume --set 5 --stream 9' with 'cmd media_session volume scripts/--set 5 --stream 9'
- Update the path for mpv command to '/data/scripts/your-new-morning-alarm.ogg'
- Enabled debugging mode to provide a more detailed log when needed.
- Modified the interval in the check_ip function to 5 seconds for better accuracy in IP retrieval attempts.
- Refactored the sleep_duration calculation to ensure it accurately reflects the intended duration between adjustments.
- Adjusted the loop in gradual adjustment to start from 1, ensuring the initial values are set correctly.
- Replaced multiple consecutive '&& sleep' statements with separate lines for improved readability.
- Simplified the error handling in check_ip and check_notification functions for clarity.
- Removed unnecessary '|| true' statements in error handling.
- Added echo statements to print the light status when it is off in check_external_light_status.
- Improved comments for better script understanding.
These changes enhance the script's execution, improve debugging capabilities, and make the code more readable and maintainable.
- Simplified calculation of brightness_step and colortemp_step for better readability.
- Corrected the calculation of reached final values for brightness and color temperature.
- Introduced sleep_duration variable for improved flexibility in sleep intervals.
- Adjusted the loop to start from 0 to correctly set the initial values.
- Added a comment to clarify the purpose of the loop and its iteration.
- Set the current_brightness and current_colortemp directly to the end values after the loop, ensuring they reach the intended final values.
- Moved the sleep_duration calculation inside the loop for consistency.
This refactoring enhances the script's clarity and ensures accurate calculation of brightness and color temperature steps during the gradual adjustment process. The changes also include improvements in sleep duration handling.
- Updated comments for better clarity and documentation
- Introduced a DEBUG variable to toggle debugging information
- Utilized set -e to stop the script on errors for better error handling
- Corrected the script flow to ensure proper execution of color changes
- Introduced a new ssh_command function for executing SSH commands
- Improved check_ip function for finding the IP address more reliably
- Added DEBUG checks to bypass certain functions for debugging purposes
- Fixed issues with sleep intervals during script execution
- Improved logging by adding echo statements for important steps
- Adjusted variable names for better readability
- Removed unnecessary comments and debug statements
- Added set -e for better error handling
- Introduced command-line option -d for enabling DEBUG mode
- Improved formatting and indentation for better code readability
- Updated comments for better clarity and documentation
- Introduced a DEBUG variable to toggle debugging information
- Utilized set -e to stop the script on errors for better error handling
- Corrected the script flow to ensure proper execution of color changes
- Introduced a new ssh_command function for executing SSH commands
- Improved check_ip function for finding the IP address more reliably
- Added DEBUG checks to bypass certain functions for debugging purposes
- Fixed issues with sleep intervals during script execution
- Improved logging by adding echo statements for important steps
- Adjusted variable names for better readability
- Removed unnecessary comments and debug statements
- Added set -e for better error handling
- Introduced command-line option -d for enabling DEBUG mode
- Improved formatting and indentation for better code readability
- Reordered the iobroker state set commands to set colortemp at the end for better consistency.
- Removed unnecessary ping test in the check_ip function.
- Cleaned up the check_notification function, removed unnecessary echo statements.
- Adjusted the sleep time in the check_notification function to 5 seconds.
- Updated comments and removed unnecessary comments for clarity.
- Minor formatting improvements for better readability.
- Added missing code in the color change loop, now it changes colors as intended. (hopefully)
- Removed redundant comments at the end of the script.
These changes enhance the script's clarity, remove unnecessary code, and ensure proper functionality.
- Entfernen des nicht benötigten Ping-Tests in der check_ip-Funktion.
- Kommentieren des Codes zum Löschen überholter 'at'-Jobs, da er derzeit auskommentiert ist (Muss ich mich ein anderes mal drum kümmern).
- Modified the IP resolution process to allow for multiple attempts with a specified interval.
- Added a retry mechanism to check the IP address multiple times before considering it unsuccessful.
- If the target IP cannot be found after the specified number of attempts, an error message is displayed.
- Updated the SSH command to run the alarm script in the background.
- Modified the IP resolution process to allow for multiple attempts with a specified interval.
- Added a retry mechanism to check the IP address multiple times before considering it unsuccessful.
- If the target IP cannot be found after the specified number of attempts, an error message is displayed.
- Updated the SSH command to run the alarm script in the background.
- Combined IP retrieval and ping test into a single function 'check_ip'.
- Improved error handling for better script robustness.
- Removed unnecessary commented-out code and added comments for clarity.
- Ensured consistency in indentation and formatting.
Author: Michael, Haider
Date: 22.12.2023
- Corrected the calculation of the variable 'lightsOn' to ensure the correct time is set for turning on lights.
- Refactored the script by combining the IP retrieval and ping test into a single function 'check_ip'.
- Improved error handling and added comments for better readability.
Author: Michael, Haider
Date: 22.12.2023
Modified delete_expired_at_jobs function to retain only the next 'at'-job and delete all upcoming jobs. This ensures that only the immediate 'at'-job remains scheduled.
- Geänderte Mac-Adresse für die Funktion check_ip.
- Verwende 'arp-scan' für die IP-Ermittlung.
- Verbesserte Ausgabe und Wartezeit in der Funktion check_notification.
- Start des Alarm-Scripts auf dem Handy mit protokollierter Ausgabe.
- Geänderte Mac-Adresse für Lisas iPhone in check_ip-Funktion.
- Verbesserte Ausgabe und Wartezeit in der check_notification-Funktion.
- Angepasste Schritte und Dauer für die Helligkeits- und Farbtemperaturanpassung.
- Start des Alarm-Scripts auf dem Handy ohne protokollierte Ausgabe.
- Änderung des Bluetooth-Ausschaltbefehls zu 'svc bluetooth disable'.
- Aktualisierung des Lautstärke-Erhöhungsbefehls.
- Verbesserte Ausgabe in der check_notification-Funktion.
- Entfernung des Timeout-Befehls bei der Überprüfung der Weckerbenachrichtigung.
- Hinzufügen von 'killall mpv' bei Beendigung des Weckers.
- Geänderte Mac-Adresse für Lisas iPhone in check_ip-Funktion.
- Verbesserte Ausgabe in der check_notification-Funktion.
- Angepasste Schritte und Dauer für die Helligkeits- und Farbtemperaturanpassung.
- Start des Alarm-Scripts auf dem Handy mit protokollierter Ausgabe.
- Adjusted the 'check_notification' function to execute the SSH command within a timeout.
- Modified the logging of wecker.sh start and end times for better monitoring.
Changes:
- Modified line 41 in wecker.sh to execute the SSH command within a timeout for 'check_notification' function
from:
output= [0] "Beenden" -> PendingIntent{cb58c43: PendingIntentRecord{9bf5dfe com.urbandroid.sleep startActivity (allowlist: 27215bc:+30s0ms/0/NOTIFICATION_SERVICE/NotificationManagerService)}}
to:
output=Timeout
- Added date and echo statements to log the start and end times in 'check_notification' function.
- Moved the 'ssh root@ '/data/scripts/morning-alarm.sh'' line to the end of the script to trigger the morning alarm.
Author: Michael Haider
Date: 17.12.2023
Adjusted the wecker.sh invocation in A72_alarm_getter.sh to redirect output to /root/wecker.log for better logging. Now, when scheduling a new alarm, the script will log the wecker.sh execution details to the log file.
Changes:
- Modified line 87 in A72_alarm_getter.sh to redirect wecker.sh output to /root/wecker.log
from:
echo "/root/iobroker_scripts/schlafzimmer/wecker.sh" | at ""
to:
echo "/root/iobroker_scripts/schlafzimmer/wecker.sh > /root/wecker.log" | at ""
Author: Michael Haider
Date: 17.12.2023
This script turns off Bluetooth, increases the media volume to 100%, and continuously checks if the alarm has been dismissed on the Android device. Additionally, it plays the morning alarm sound in an infinite loop until the alarm is dismissed.
- Script Name: morning-alarm.sh
- Features:
- Turn off Bluetooth
- Set media volume to 100%
- Play the morning alarm sound in an infinite loop
- Continuously check for alarm dismissal
Author: Michael Haider
Date: 17.12.2023
- Removed unnecessary variable interpolation in the 'echo' statement.
- Changed the path for 'atq' and 'atrm' commands to use the full path.
- Updated the 'ping' command to use the full path for better compatibility.
- Added comments and improved formatting for better script understanding.
In this commit, an echo statement is added to display the execution timestamp
in the A72_alarm_getter.sh script. The timestamp is printed with the command
'echo 'Ausgeführt um: ''.
Additionally, the script now contains a function called delete_expired_at_jobs
to check and delete expired 'at' jobs. The current time is obtained using the
'date' command and stored in the variable current_time.
1. Added a new function `check_external_light_status` to check if the light is turned off externally.
2. Modified the condition in the `check_notification` function to correctly check if the notification contains "[1]" and the specified strings.
3. Corrected the assignment statement inside the `while` loop. Changed `first_brightness_cmason.nvimhange=false` to `first_brightness_change=false`.