Remove 2b2t queue, silent errors of covid prompt and use busctl for better mpris output parsing

This commit is contained in:
Alex 2020-04-15 14:13:26 +02:00
parent 673f2ca947
commit 40aa1b85c7
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
2 changed files with 5 additions and 17 deletions

View File

@ -1,5 +1,4 @@
typeset -gi _mail_change_time
typeset -gi _mclog_change_time
typeset -gi _pacman_check_time
typeset -gi _mail_count
typeset -gi _upgrade_packages
@ -9,11 +8,11 @@ function prompt_docker_host() {
typeset -g POWERLEVEL9K_DOCKER_HOST_SHOW_ON_COMMAND='docker'
function prompt_dbus_mpris() {
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
typeset -g _mpris_RFMT="$(print ${_mpris_RESP} | grep -oP '(?<=^xesam:title: ).+')"
local ARTIST="$(print ${_mpris_RESP} | grep -oP '(?<=^xesam:artist: ).+')"
[ ! -z ${ARTIST} ] && _mpris_RFMT="${ARTIST} - ${_mpris_RFMT}"
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%% \(*\)}"
fi
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}"
}
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() {
local tmpfile=/tmp/covidres
local -a stats
zstat -A stats +mtime -- $tmpfile 2>/dev/null
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
fi
p10k segment -b red -i '' -t "$(< $tmpfile)"

View File

@ -30,7 +30,6 @@ if [ -z "$SSH_CONNECTION" ] && ! [ -z "$DISPLAY" ]; then
vim_shell
new_mail
covid_19
2b2t_queue
dbus_mpris
public_ip
newline