Remove 2b2t queue, silent errors of covid prompt and use busctl for better mpris output parsing
This commit is contained in:
parent
673f2ca947
commit
40aa1b85c7
|
@ -1,5 +1,4 @@
|
||||||
typeset -gi _mail_change_time
|
typeset -gi _mail_change_time
|
||||||
typeset -gi _mclog_change_time
|
|
||||||
typeset -gi _pacman_check_time
|
typeset -gi _pacman_check_time
|
||||||
typeset -gi _mail_count
|
typeset -gi _mail_count
|
||||||
typeset -gi _upgrade_packages
|
typeset -gi _upgrade_packages
|
||||||
|
@ -9,11 +8,11 @@ function prompt_docker_host() {
|
||||||
typeset -g POWERLEVEL9K_DOCKER_HOST_SHOW_ON_COMMAND='docker'
|
typeset -g POWERLEVEL9K_DOCKER_HOST_SHOW_ON_COMMAND='docker'
|
||||||
function prompt_dbus_mpris() {
|
function prompt_dbus_mpris() {
|
||||||
typeset -g _mpris_LASTRESP="${_mpris_RESP:-0}"
|
typeset -g _mpris_LASTRESP="${_mpris_RESP:-0}"
|
||||||
typeset -g _mpris_RESP="$(qdbus org.mpris.MediaPlayer2.mpv /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata 2>/dev/null)"
|
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')"
|
||||||
if [[ $_mpris_RESP != $_mpris_LASTRESP ]]; then
|
if [[ $_mpris_RESP != $_mpris_LASTRESP ]]; then
|
||||||
typeset -g _mpris_RFMT="$(print ${_mpris_RESP} | grep -oP '(?<=^xesam:title: ).+')"
|
typeset -g _mpris_RFMT="$(print ${_mpris_RESP} | jq --raw-output '."xesam:title".data // ""')"
|
||||||
local ARTIST="$(print ${_mpris_RESP} | grep -oP '(?<=^xesam:artist: ).+')"
|
local ARTIST="$(print ${_mpris_RESP} | jq --raw-output '."xesam:artist".data[0] // ""')"
|
||||||
[ ! -z ${ARTIST} ] && _mpris_RFMT="${ARTIST} - ${_mpris_RFMT}"
|
[ ! -z ${ARTIST} ] && _mpris_RFMT="${ARTIST} - ${_mpris_RFMT%% \(*\)}"
|
||||||
fi
|
fi
|
||||||
p10k segment -b purple -i '' -t "${_mpris_RFMT}" -c "${_mpris_RFMT}"
|
p10k segment -b purple -i '' -t "${_mpris_RFMT}" -c "${_mpris_RFMT}"
|
||||||
}
|
}
|
||||||
|
@ -36,22 +35,12 @@ function prompt_pacman_upgrade() {
|
||||||
p10k segment -b cyan -i '' -t "${_upgrade_packages}"
|
p10k segment -b cyan -i '' -t "${_upgrade_packages}"
|
||||||
}
|
}
|
||||||
typeset -g POWERLEVEL9K_PACMAN_UPGRADE_SHOW_ON_COMMAND='pacman'
|
typeset -g POWERLEVEL9K_PACMAN_UPGRADE_SHOW_ON_COMMAND='pacman'
|
||||||
function prompt_2b2t_queue() {
|
|
||||||
local FILE=~/.local/share/multimc/instances/Impact\ 4.8.3\ -\ 1.12.2\ -\ Forge/.minecraft/logs/latest.log
|
|
||||||
local -a stats
|
|
||||||
zstat -A stats +mtime -- $FILE 2>/dev/null || return
|
|
||||||
if [[ $stats[1] != $_mclog_change_time ]]; then
|
|
||||||
local _last_LOG=($(tail -n1 $FILE))
|
|
||||||
_mclog_change_time=$stats[1]
|
|
||||||
fi
|
|
||||||
[ ${_last_LOG[-2]:-0} = 'queue:' ] && p10k segment -b green -i '' -t "${_last_LOG[-1]}"
|
|
||||||
}
|
|
||||||
function prompt_covid_19() {
|
function prompt_covid_19() {
|
||||||
local tmpfile=/tmp/covidres
|
local tmpfile=/tmp/covidres
|
||||||
local -a stats
|
local -a stats
|
||||||
zstat -A stats +mtime -- $tmpfile 2>/dev/null
|
zstat -A stats +mtime -- $tmpfile 2>/dev/null
|
||||||
if [[ $stats[1] < $(($epochtime[1]-86400)) ]]; then
|
if [[ $stats[1] < $(($epochtime[1]-86400)) ]]; then
|
||||||
local result=$(curl -sS https://api.covid19api.com/country/germany/status/confirmed/live | jq -e '.[-1].Cases')
|
local result=$(curl -sL https://api.covid19api.com/country/germany/status/confirmed/live | jq -e '.[-1].Cases')
|
||||||
[ ! -z $result ] && print $result > $tmpfile
|
[ ! -z $result ] && print $result > $tmpfile
|
||||||
fi
|
fi
|
||||||
p10k segment -b red -i '' -t "$(< $tmpfile)"
|
p10k segment -b red -i '' -t "$(< $tmpfile)"
|
||||||
|
|
|
@ -30,7 +30,6 @@ if [ -z "$SSH_CONNECTION" ] && ! [ -z "$DISPLAY" ]; then
|
||||||
vim_shell
|
vim_shell
|
||||||
new_mail
|
new_mail
|
||||||
covid_19
|
covid_19
|
||||||
2b2t_queue
|
|
||||||
dbus_mpris
|
dbus_mpris
|
||||||
public_ip
|
public_ip
|
||||||
newline
|
newline
|
||||||
|
|
Loading…
Reference in New Issue