#!/bin/bash
#
# Status OrangePi Zero pour Svxlink
# F4GFZ Juillet 2023
temp=$( cat /sys/devices/virtual/thermal/thermal_zone0/temp 2> '/dev/null' )
weeks=$( uptime -p |grep -Po '\w+(?=\s+week.+)' )
days=$( uptime -p |grep -Po '\w+(?=\s+day)' )
hours=$( uptime -p |grep -Po '\w+(?=\s+hour)' )
minutes=$( uptime -p |grep -Po '\w+(?=\s+minute)' )
diskusage=$( df |grep mmcb |awk '{print $5+0}' )
freemem=$( free -m |grep Mem|awk '{print int(($4*100)/$2)}' )
echo 'playMsg "Status" "status";'
# uptime
echo 'playMsg "Status" "uptime";'
if [ ! -z $days ]; then
if [ ! -z $weeks ]; then echo 'playNumber '$(($days + ($weeks * 7)))';'; else echo 'playNumber '$(($days))';'; fi
echo 'playMsg "Status" "jours";'
echo 'playMsg "Status" "and";'
fi
if [ ! -z $hours ]; then echo 'playNumber '$(($hours))';'; echo 'playMsg "Status" "hours";'; else echo 'playNumber '$(($minutes))';'; echo 'playMsg "Status" "minutes";'; fi
# temperature
echo 'playMsg "Status" "temperature";'
echo 'playNumber '$(($temp/1000))';'
echo 'playMsg "Status" "unit_degrees";'
# disk space
echo 'playMsg "Status" "freespace";'
echo 'playNumber '$((100-$diskusage))';'
echo 'playMsg "Status" "percent";'
# memory space
echo 'playMsg "Status" "freememory";'
echo 'playNumber '$(($freemem))';'
echo 'playMsg "Status" "percent";'