2019-10-10 22:52:49 -04:00
|
|
|
#! /bin/bash
|
|
|
|
|
|
|
|
stat_file=/tmp/.conky_pacman
|
|
|
|
log_file=/var/log/pacman.log
|
|
|
|
|
2019-10-11 21:52:10 -04:00
|
|
|
get_log_date() {
|
|
|
|
sed -n "s/\[\(.*\)\] \[PACMAN\] $1/\1/p" \
|
|
|
|
/var/log/pacman.log | \
|
|
|
|
tail -1 \
|
|
|
|
| { read -r f; date -d "$f" +%m-%d-%Y; }
|
|
|
|
}
|
|
|
|
|
2019-10-10 22:52:49 -04:00
|
|
|
write_stats() {
|
|
|
|
now=$(date +%s)
|
2019-10-11 21:52:10 -04:00
|
|
|
last_upgrade=$(get_log_date "starting full system upgrade")
|
|
|
|
last_sync=$(get_log_date "synchronizing package lists")
|
2019-10-10 22:52:49 -04:00
|
|
|
tot=$(pacman -Qq | wc -l)
|
|
|
|
exp=$(pacman -Qeq | wc -l)
|
|
|
|
out=$(pacman -Quq | wc -l)
|
|
|
|
orp=$(pacman -Qdtq | wc -l)
|
|
|
|
loc=$(pacman -Qmq | wc -l)
|
2019-10-11 21:52:10 -04:00
|
|
|
echo "$now" "$last_upgrade" "$last_sync" "$tot" "$exp" "$out" \
|
|
|
|
"$orp" "$loc" > "$stat_file"
|
2019-10-10 22:52:49 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if [[ -f "$stat_file" ]]; then
|
|
|
|
last_pacman_update=$(stat -c %Y "$log_file")
|
|
|
|
last_stat_update=$(awk '{ print $1 }' "$stat_file")
|
|
|
|
if (( last_pacman_update > last_stat_update )); then
|
|
|
|
write_stats
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
write_stats
|
|
|
|
fi
|
|
|
|
|