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
This commit is contained in:
parent
b568784db3
commit
6dec897849
2 changed files with 25 additions and 2 deletions
|
@ -61,6 +61,8 @@ echo "$ids" | while read -r id; do
|
|||
|
||||
log="$SMS_DIR/$number/sms.log"
|
||||
|
||||
[ ! -f "$log" ] && printf '\00READ\00' >> "$log"
|
||||
|
||||
# Store the message in the log file
|
||||
echo "RECIEVED"
|
||||
echo "SENDER: $number" >> $log
|
||||
|
|
|
@ -1,10 +1,31 @@
|
|||
#!/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")"
|
||||
|
||||
notify-send "$(hostname)" "$batteryIcon ${battery}%\nTime $time"
|
||||
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"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue