Diverses modifs
This commit is contained in:
parent
62004a2348
commit
2f111c4013
7 changed files with 30 additions and 33 deletions
.i3blocks
|
@ -3,7 +3,7 @@
|
|||
# Fonction de réinitialisation en cas de perte de la connexion
|
||||
self-reset() {
|
||||
echo "<span foreground=\"#515151\">[--:-- --:-- --:--]</span>"
|
||||
sleep 5
|
||||
sleep 1
|
||||
exec "$0"
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ coproc nc -U /home/breizh/.mpd/socket
|
|||
IN=${COPROC[1]}
|
||||
OUT=${COPROC[0]}
|
||||
#echo "password xxx" >&"${IN}"
|
||||
sed '/^OK/q' <&"$OUT" &>/dev/null
|
||||
#sed '/^OK/q' <&"$OUT" &>/dev/null
|
||||
|
||||
# Initialisation des valeurs par défaut et des fonctions
|
||||
declare -i SCROLL=50 I=0
|
||||
|
@ -43,10 +43,9 @@ human_time() {
|
|||
|
||||
# Initialisation de l’état
|
||||
echo "status" >&"$IN"
|
||||
while read -t 1 -u "$OUT" output
|
||||
while read -t 0.1 -u "$OUT" output
|
||||
do
|
||||
[[ "$output" == "OK" ]] && break
|
||||
o[${output%%:*}]="${output##*: }"
|
||||
[[ "$output" =~ : ]] && o[${output%%:*}]="${output##*: }"
|
||||
done
|
||||
|
||||
# Boucle principale
|
||||
|
@ -54,8 +53,8 @@ while [[ -n "$COPROC_PID" ]]
|
|||
do
|
||||
# Gestion du clic, fait office de délai si aucune action (une seconde).
|
||||
# En cas de clic, l’actualisation de l’affichage sera instantanné.
|
||||
read -t 1 BLOCK_BUTTON
|
||||
|
||||
read -t 0.75 BLOCK_BUTTON
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1|3)
|
||||
if [[ "${o["state"]}" == stop ]]
|
||||
|
@ -77,25 +76,23 @@ do
|
|||
1|2|3) sed '/^OK$/q' <&"$OUT" &>/dev/null ;;
|
||||
4) I="I-2"; [[ "$I" -lt 0 ]] && I=0 ;;
|
||||
esac
|
||||
|
||||
|
||||
# Réinitialisation de l’état
|
||||
unset o output
|
||||
declare -A o
|
||||
|
||||
|
||||
# Récupération de l’état
|
||||
echo "status" >&"$IN" || self-reset
|
||||
while read -t 1 -u "$OUT" output
|
||||
while read -t 0.1 -u "$OUT" output
|
||||
do
|
||||
[[ "$output" == "OK" ]] && break
|
||||
o[${output%%:*}]="${output##*: }"
|
||||
[[ "$output" =~ : ]] && o[${output%%:*}]="${output##*: }"
|
||||
done
|
||||
|
||||
# Récupération des informations du morceau en cours
|
||||
echo "currentsong" >&"$IN" || self-reset
|
||||
while read -t 1 -u "$OUT" output
|
||||
while read -t 0.1 -u "$OUT" output
|
||||
do
|
||||
[[ "$output" == "OK" ]] && break
|
||||
o[${output%%:*}]="${output##*: }"
|
||||
[[ "$output" =~ : ]] && o[${output%%:*}]="${output##*: }"
|
||||
done
|
||||
|
||||
# Choix des couleurs selon l’état
|
||||
|
@ -120,7 +117,7 @@ do
|
|||
scroll=true
|
||||
song=" $song "
|
||||
else
|
||||
scroll=false
|
||||
unset scroll
|
||||
song=" $song"
|
||||
fi
|
||||
|
||||
|
@ -131,7 +128,7 @@ do
|
|||
fi
|
||||
|
||||
# Gestion du défilement
|
||||
if "$scroll"
|
||||
if [[ -n "$scroll" ]]
|
||||
then
|
||||
unset bloc1 bloc2 bloc3 bloc4
|
||||
declare -- bloc1 bloc2 bloc3 bloc4
|
||||
|
@ -190,3 +187,5 @@ do
|
|||
# DEBUG
|
||||
printf '<b>%s</b>%s<b>%s</b>%s%s\n' "$bloc1" "$bloc2" "$bloc3" "$bloc4" " $status$time</span>"
|
||||
done
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue