Mise à jour

This commit is contained in:
Breizh 2020-01-09 21:17:01 +01:00
parent 37d249b9d1
commit 71e2ac2ef3
27 changed files with 206 additions and 431 deletions
.i3blocks

View file

@ -1,5 +1,8 @@
#!/bin/bash
runtime="${XDG_RUNTIME_DIR}/i3blocks"
[[ ! -d "$runtime" ]] && mkdir -p "$runtime"
if ! systemctl --user is-active mpd &>/dev/null
then
origstatus='off'
@ -8,8 +11,8 @@ else
[[ -z "$origstatus" ]] && origstatus='stop'
fi
LONG=25
SHORT=10
LONG=30
SHORT=15
case $BLOCK_BUTTON in
1) mpc -q prev ;;
@ -49,12 +52,12 @@ esac
if [[ "$origstatus" != "stop" ]] && [[ "$origstatus" != "off" ]]
then
if [[ ! -f /dev/shm/mpd ]]
if [[ ! -f $runtime/mpd ]]
then
mpc -f '[[%artist%§]%title%|[%file%]' current > /dev/shm/mpd
mpc -f '[[%artist%§]%title%|[%file%]' current > ${runtime}/mpd
fi
song=$(</dev/shm/mpd)
song=$(<${runtime}/mpd)
if [[ "${#song}" -gt $LONG ]]
then
@ -68,15 +71,15 @@ then
if [[ "$scrolling" != "none" ]]
then
scroll="$(</dev/shm/mpd-scroll)"
scroll="$(<${runtime}/mpd-scroll)"
if [[ -z "${scroll// /}" ]]
then
printf "%-${LONG}s" "$(</dev/shm/mpd)" > /dev/shm/mpd-scroll
song="$(</dev/shm/mpd-scroll)"
printf "%-${LONG}s" "$(<${runtime}/mpd)" > ${runtime}/mpd-scroll
song="$(<${runtime}/mpd-scroll)"
else
song="$(</dev/shm/mpd-scroll)"
printf "%-${LONG}s" "${song:1}" > /dev/shm/mpd-scroll
song="$(<${runtime}/mpd-scroll)"
printf "%-${LONG}s" "${song:1}" > ${runtime}/mpd-scroll
fi
fi
@ -96,11 +99,11 @@ then
shortsong="${song} "
;;
short)
longsong="$(</dev/shm/mpd) "
longsong="$(<${runtime}/mpd) "
shortsong="${song} "
;;
none)
longsong="$(</dev/shm/mpd) "
longsong="$(<${runtime}/mpd) "
shortsong="$longsong"
;;
esac
@ -112,24 +115,24 @@ then
if [[ "$longsong" =~ § ]]
then
longsong="<i>${longsong/§/</i> }"
longsong="<u>${longsong/§/</u> }"
elif [[ "$song" =~ § ]]
then
longsong="<i>${longsong}</i>"
longsong="<u>${longsong}</u>"
fi
if [[ "$shortsong" =~ § ]]
then
shortsong="<i>${shortsong/§/</i> }"
shortsong="<u>${shortsong/§/</u> }"
elif [[ "$song" =~ § ]]
then
shortsong="<i>${shortsong}</i>"
shortsong="<u>${shortsong}</u>"
fi
echo "${longsong} $status$longtime</span>"
echo "${shortsong} $status$shorttime</span>"
else
[[ -f /dev/shm/mpd ]] && rm /dev/shm/mpd
[[ -f /dev/shm/mpd-scroll ]] && rm /dev/shm/mpd-scroll
[[ -f ${runtime}/mpd ]] && rm ${runtime}/mpd
[[ -f ${runtime}/mpd-scroll ]] && rm ${runtime}/mpd-scroll
printf "%${LONG}s $status[--:-- --:-- --:--]</span>\n" " "
printf "%${SHORT}s $status--:-- --:--</span>\n" " "
fi