2020-04-14 18:09:10 +00:00
|
|
|
typeset -gi _mail_change_time
|
|
|
|
typeset -gi _pacman_check_time
|
|
|
|
typeset -gi _mail_count
|
|
|
|
typeset -gi _upgrade_packages
|
2020-04-06 21:30:24 +00:00
|
|
|
function prompt_docker_host() {
|
2020-04-14 18:09:10 +00:00
|
|
|
p10k segment -b blue -i '' -t "${DOCKER_HOST#*://}" -c "${DOCKER_HOST#*://}"
|
2020-04-06 21:30:24 +00:00
|
|
|
}
|
|
|
|
typeset -g POWERLEVEL9K_DOCKER_HOST_SHOW_ON_COMMAND='docker'
|
|
|
|
function prompt_dbus_mpris() {
|
2020-04-14 18:09:10 +00:00
|
|
|
typeset -g _mpris_LASTRESP="${_mpris_RESP:-0}"
|
2020-04-15 12:13:26 +00:00
|
|
|
typeset -g _mpris_RESP="$(busctl --user --json=short get-property org.mpris.MediaPlayer2.mpv /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player Metadata 2>/dev/null | jq '.data')"
|
2020-04-06 21:30:24 +00:00
|
|
|
if [[ $_mpris_RESP != $_mpris_LASTRESP ]]; then
|
2020-04-15 12:13:26 +00:00
|
|
|
typeset -g _mpris_RFMT="$(print ${_mpris_RESP} | jq --raw-output '."xesam:title".data // ""')"
|
|
|
|
local ARTIST="$(print ${_mpris_RESP} | jq --raw-output '."xesam:artist".data[0] // ""')"
|
|
|
|
[ ! -z ${ARTIST} ] && _mpris_RFMT="${ARTIST} - ${_mpris_RFMT%% \(*\)}"
|
2020-04-06 21:30:24 +00:00
|
|
|
fi
|
|
|
|
p10k segment -b purple -i '' -t "${_mpris_RFMT}" -c "${_mpris_RFMT}"
|
|
|
|
}
|
|
|
|
function prompt_new_mail() {
|
2020-04-14 18:09:10 +00:00
|
|
|
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}"
|
2020-04-06 21:30:24 +00:00
|
|
|
}
|
|
|
|
function prompt_pacman_upgrade() {
|
2020-04-14 18:09:10 +00:00
|
|
|
if [[ $_pacman_check_time < $(($epochtime[1]-86400)) ]]; then
|
|
|
|
_upgrade_packages=$(pacman -Qu | wc -l)
|
|
|
|
_pacman_check_time=$epochtime[1]
|
|
|
|
fi
|
|
|
|
(( $_upgrade_packages > 0 )) || return
|
|
|
|
p10k segment -b cyan -i '' -t "${_upgrade_packages}"
|
2020-04-06 21:30:24 +00:00
|
|
|
}
|
|
|
|
typeset -g POWERLEVEL9K_PACMAN_UPGRADE_SHOW_ON_COMMAND='pacman'
|
2020-04-14 18:09:10 +00:00
|
|
|
function prompt_covid_19() {
|
|
|
|
local tmpfile=/tmp/covidres
|
|
|
|
local -a stats
|
|
|
|
zstat -A stats +mtime -- $tmpfile 2>/dev/null
|
|
|
|
if [[ $stats[1] < $(($epochtime[1]-86400)) ]]; then
|
2020-04-15 12:13:26 +00:00
|
|
|
local result=$(curl -sL https://api.covid19api.com/country/germany/status/confirmed/live | jq -e '.[-1].Cases')
|
2020-04-14 18:09:10 +00:00
|
|
|
[ ! -z $result ] && print $result > $tmpfile
|
|
|
|
fi
|
|
|
|
p10k segment -b red -i '' -t "$(< $tmpfile)"
|
|
|
|
}
|