Dotfiles/bin/.bin/notifications/phoneStatus
Jonathan Hodgson 6dec897849 Changes the sms log file so that new messages can be counted
The log now contains @READ@ where @ is a null byte where new and old
messages diverge. This means that new sms's can be more easily counted

This, as well as a count for missed calls, has been added to the
phoneStatus notification
2021-04-05 10:23:39 +01:00

31 lines
894 B
Bash
Executable file

#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source "$DIR/../modem/common"
battery="$(cat /sys/class/power_supply/axp20x-battery/capacity)"
batteryStatus="$(cat /sys/class/power_supply/axp20x-battery/status)"
[ "$batteryStatus" = "Charging" ] && batteryIcon="🔌" || batteryIcon="🔋"
missedCallsNo="$(cat "$CALL_DIR/missed-calls" | wc -l )"
time="$(date "+%H:%M")"
newTexts=0
for i in "$SMS_DIR"/*/sms.log; do
echo "$i"
count="$(sed -n '/\x0READ\x0/,$ p' "$i" | sed '1d' |
sed -n 's/\x0/-/p' | wc -l)"
echo "$count"
newTexts=$(( newTexts + count ))
done
notification="
$batteryIcon ${battery}%
Time $time
$( [ "$missedCallsNo" -gt 0 ] && echo "$missedCallsNo Missed Calls" )
$( [ "$newTexts" -gt 0 ] && echo "$newTexts New Texts" )"
notification="$( echo "$notification" | sed '/^$/d' )"
notify-send "$(hostname)" "$notification"