aboutsummaryrefslogtreecommitdiff
path: root/scripts/.local/bin/personal/syshealth
blob: 5c7ebe59e2ab49f638476db4624f4a41b1216d0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash

# NOTE: This script is run by cron periodically

export XDG_RUNTIME_DIR="/run/user/$(id -u)"
export DISPLAY=":0"

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 VOLTAGE critical")
temperature_message=("Warning:" "Core TEMPERATURE critical")

if ((${local_percent::-2} <= 15)); then
  if [[ "${local_state::-1}" == "Discharging" ]]; then
    /usr/bin/notify-send -u critical "   ${battery_message[0]} ${battery_message[1]}" &
    # espeak "${battery_message[0]}${battery_message[1]}"
  fi
elif ((${local_percent::-2} >= 90)); then
  if [[ "${local_state::-1}" == "Charging" ]]; then
    /usr/bin/notify-send -u critical "   ${battery_message[0]} ${battery_message[1]}" &
    # 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
  /usr/bin/notify-send -u critical "  ${temperature_message[0]} ${temperature_message[1]}" &
  # espeak "${temperature_message[0]}${temperature_message[1]}"
fi