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
parent
f1dd615869
commit
5b05bb9c2c
2 changed files with 25 additions and 2 deletions
@ -1,10 +1,31 @@ |
|||||||
#!/usr/bin/env bash |
#!/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)" |
battery="$(cat /sys/class/power_supply/axp20x-battery/capacity)" |
||||||
batteryStatus="$(cat /sys/class/power_supply/axp20x-battery/status)" |
batteryStatus="$(cat /sys/class/power_supply/axp20x-battery/status)" |
||||||
[ "$batteryStatus" = "Charging" ] && batteryIcon="🔌" || batteryIcon="🔋" |
[ "$batteryStatus" = "Charging" ] && batteryIcon="🔌" || batteryIcon="🔋" |
||||||
|
missedCallsNo="$(cat "$CALL_DIR/missed-calls" | wc -l )" |
||||||
time="$(date "+%H:%M")" |
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…
Reference in new issue