Use shell built-in globbing and check pacman updates by /sync folder modification time, move tmp file for covid stats

This commit is contained in:
Alex 2020-04-16 03:02:54 +02:00
parent 71b1feba6e
commit bf0c2e52a8
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
1 changed files with 8 additions and 12 deletions

View File

@ -1,4 +1,3 @@
typeset -gi _mail_change_time
typeset -gi _pacman_check_time
typeset -gi _mail_count
typeset -gi _upgrade_packages
@ -17,26 +16,23 @@ function prompt_dbus_mpris() {
p10k segment -b purple -i '' -t "${_mpris_RFMT}" -c "${_mpris_RFMT}"
}
function prompt_new_mail() {
local -a stats
zstat -A stats +mtime -- ~/Mail/*/Inbox/new 2>/dev/null || return
if [[ $stats[1] != $_mail_change_time ]]; then
_mail_count=$(find ~/Mail/*/Inbox/new -type f | wc -l)
_mail_change_time=$stat[1]
fi
(( $_mail_count > 0 )) || return
p10k segment -b yellow -i '' -t "${_mail_count}"
_mail_count=(~/Mail/*/Inbox/new/*(.N))
(( ${#_mail_count} > 0 )) || return
p10k segment -b yellow -i '' -t "${#_mail_count}"
}
function prompt_pacman_upgrade() {
if [[ $_pacman_check_time < $(($epochtime[1]-86400)) ]]; then
local -a stats
zstat -A stats +mtime -- /var/lib/pacman/sync 2>/dev/null
if [[ $stats[1] != $_pacman_check_time ]]; then
_upgrade_packages=$(pacman -Qu | wc -l)
_pacman_check_time=$epochtime[1]
_pacman_check_time=$stats[1]
fi
(( $_upgrade_packages > 0 )) || return
p10k segment -b cyan -i '' -t "${_upgrade_packages}"
}
typeset -g POWERLEVEL9K_PACMAN_UPGRADE_SHOW_ON_COMMAND='pacman'
function prompt_covid_19() {
local tmpfile=/tmp/covidres
local tmpfile=~/.cache/covidres
local -a stats
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [[ $stats[1] < $(($epochtime[1]-86400)) ]]; then