Hide mpv if state changed but nothing's playing

This commit is contained in:
Alex 2020-05-23 00:14:43 +02:00
parent 1492571cba
commit de6c28f50d
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
1 changed files with 2 additions and 1 deletions

View File

@ -78,6 +78,7 @@ function prompt_weather() {
function prompt_mpv_mpris() {
typeset -g _cprompts_mpv
local busout="$(busctl get-property -j --no-pager --timeout=300ms --user org.mpris.MediaPlayer2.mpv /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player Metadata 2>/dev/null)"
[ -z $busout ] || _cprompts_mpv="$(print $busout | jq -er '.data."xesam:title".data // empty')"
[ -z $busout ] && return
_cprompts_mpv="$(print $busout | jq -er '.data."xesam:title".data // empty')"
[ -z $_cprompts_mpv ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv:0:25}$([ ${#_cprompts_mpv} -gt 25 ] && print ...)"
}