diff options
author | davidpkj <davidpenkow1@gmail.com> | 2023-03-15 14:09:28 +0100 |
---|---|---|
committer | davidpkj <davidpenkow1@gmail.com> | 2023-03-15 14:09:28 +0100 |
commit | 08a332d0daa13e52e4c8ae9bf2dbcb6408041a34 (patch) | |
tree | b75fbf58009572ed8edeb81452276ff6d5d66ec8 /scripts/.local/bin/personal/syshealth | |
parent | 2c71b057b66f817ca66b3a16eba901a9d214a3cb (diff) |
Cleaned up some scripts
Diffstat (limited to 'scripts/.local/bin/personal/syshealth')
-rwxr-xr-x | scripts/.local/bin/personal/syshealth | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/.local/bin/personal/syshealth b/scripts/.local/bin/personal/syshealth new file mode 100755 index 0000000..b60b122 --- /dev/null +++ b/scripts/.local/bin/personal/syshealth @@ -0,0 +1,38 @@ +#!/bin/bash + +# NOTE: This script is run by cron periodically + +export XDG_RUNTIME_DIR="/run/user/$(id -u)" + +acpi_report="$(acpi | grep -v unavailable | head -n 1)" +sensors_report="$(sensors | grep "Package id 0:")" + +# Battery charge check +local_percent="$(echo $acpi_report | awk '{print $4}')" +local_state="$(echo $acpi_report | awk '{print $3}')" +local_time="$(echo $acpi_report | awk '{print $5}')" + +battery_message=("Warning: " "Battery charge critical") +temperature_message=("Warning: " "Core temperature critical") + +if ((${local_percent::-2} <= 15)); then + if [[ "${local_state::-1}" == "Discharging" ]]; then + notify-send "${battery_message[0]}" "${battery_message[1]}" -u critical + # espeak "${battery_message[0]}${battery_message[1]}" + fi +elif ((${local_percent::-2} >= 90)); then + if [[ "${local_state::-1}" == "Charging" ]]; then + notify-send "${battery_message[0]}" "${battery_message[1]}" -u critical + # espeak "${battery_message[0]}${battery_message[1]}" + fi +fi + +# Core temperature check +local_temp="$(echo $sensors_report | awk '{print $4}' | sed 's/+//g')" +local_temp_high="$(echo $sensors_report | awk '{print $7}' | sed 's/+//g')" + +if ((${local_temp::-4} >= 90)); then + notify-send "${temperature_message[0]}" "${temperature_message[1]}" -u critical + # espeak "${temperature_message[0]}${temperature_message[1]}" +fi + |