Fix i3blocks/mpd

This commit is contained in:
Breizh 2022-08-13 01:12:58 +02:00
parent ba75e7a22e
commit 420899fae8

View file

@ -17,12 +17,12 @@ OUT=${COPROC[0]}
sed '/^OK/q' <&$OUT &>/dev/null
# Initialisation des valeurs par défaut et des fonctions
declare -i SCROLL=50 I=0
declare -i SCROLL=4time_left0 I=0
declare -- artist song oldfile
human_time() {
local seconds="$1"
if [[ "$seconds" -lt 0 ]]
local seconds="${1:-0}"
if [[ "$seconds" -le 0 ]]
then
echo "--:--"
return
@ -159,13 +159,15 @@ do
fi
# Gestion du temps
time_elapsed=$(human_time "${o["time"]%:*}")
time_total=$(human_time "${o["time"]#*:}")
time_left=$(human_time "$(( ${o["time"]#*:} - ${o["time"]%:*} ))")
time="[${time_elapsed:---:--} ${time_left:---:--} ${time_total:---:--}]"
declare -i time_elapsed time_total time_left
time_elapsed="${o["time"]%:*}"
time_total="${o["time"]#*:}"
time_left="${time_total:-${o["duration"]%.*}} - ${time_elapsed:-${o["Time"]}}"
time="[$(human_time ${time_elapsed}) $(human_time ${time_left}) $(human_time ${time_total})]"
# DEBUG
printf '<b>%s</b>%s<b>%s</b>%s%s\n' "$bloc1" "$bloc2" "$bloc3" "$bloc4" " $status$time</span>"
done
done