ZSHFiles/custom/segments/prompt_c_mpv_mpris

7 lines
499 B
Plaintext
Raw Normal View History

([ -v commands\[busctl\] ] && [ -v commands\[jq\] ]) || return
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 ] && return
_cprompts_mpv="$(print $busout | jq -er '(.data."xesam:title".data // empty)')"
[ -z $_cprompts_mpv ] || p10k segment -b magenta -i '' -t "${_cprompts_mpv:0:20}$([ ${#_cprompts_mpv} -gt 20 ] && print ...)"