Tentative renouvellement block MPD

This commit is contained in:
Breizh 2021-06-05 22:49:18 +02:00
parent b9432c0932
commit b4fe385d4f
7 changed files with 70 additions and 137 deletions

View file

@ -1,8 +1,8 @@
[Settings] [Settings]
gtk-application-prefer-dark-theme=false gtk-application-prefer-dark-theme=true
gtk-theme-name=Vertex-Dark gtk-theme-name=Vertex-Dark
gtk-icon-theme-name=Vertex-Icons gtk-icon-theme-name=Adwaita
gtk-font-name=IBM Plex Sans 11 gtk-font-name=IBM Plex Sans 10
gtk-button-images=1 gtk-button-images=1
gtk-menu-images=1 gtk-menu-images=1
gtk-enable-event-sounds=1 gtk-enable-event-sounds=1

View file

@ -353,7 +353,7 @@ bindsym $mod+9 exec --no-startup-id xscreensaver-command -activate
# Autostart applications # Autostart applications
## adjustment of i3bar battery reading (only run at the very first login): ## adjustment of i3bar battery reading (only run at the very first login):
#exec --no-startup-id /usr/bin/adjust_i3statusconf #exec --no-startup-id /usr/bin/adjust_i3statusconf
exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 #exec --no-startup-id /usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1
exec --no-startup-id conky --config "$HOME/.config/conky/conkyrc1" exec --no-startup-id conky --config "$HOME/.config/conky/conkyrc1"
exec --no-startup-id conky --config "$HOME/.config/conky/conkyrc2" exec --no-startup-id conky --config "$HOME/.config/conky/conkyrc2"
exec_always --no-startup-id setcursor exec_always --no-startup-id setcursor
@ -361,7 +361,6 @@ exec claws-mail --online
exec --no-startup-id urxvtc -name newsboat -e newsboat exec --no-startup-id urxvtc -name newsboat -e newsboat
exec --no-startup-id xinput --disable "AlpsPS/2 ALPS DualPoint TouchPad" exec --no-startup-id xinput --disable "AlpsPS/2 ALPS DualPoint TouchPad"
exec --no-startup-id redshift-gtk exec --no-startup-id redshift-gtk
exec --no-startup-id sudo radeontop -d /dev/shm/radeontop
exec --no-startup-id nm-applet exec --no-startup-id nm-applet
exec --no-startup-id steam-native -silent -noverifyfiles -language french exec --no-startup-id steam-native -silent -noverifyfiles -language french
#exec --no-startup-id SVPManager #exec --no-startup-id SVPManager

View file

@ -31,6 +31,17 @@ markup=pango
#command=echo $(xdotool getactivewindow getwindowname) #command=echo $(xdotool getactivewindow getwindowname)
#interval=1 #interval=1
# Generic media player support
#
# This displays "ARTIST - SONG" if a music is playing.
# Supported players are: spotify, vlc, audacious, xmms2, mplayer, and others.
[mpd]
#instance=spotify
interval=1
signal=13
#markup=none
# CPU usage # CPU usage
# #
# The script may be called with -w and -c switches to specify thresholds, # The script may be called with -w and -c switches to specify thresholds,
@ -145,16 +156,6 @@ interval=600
#interval=10 #interval=10
#min_width="bat ██████" #min_width="bat ██████"
# Generic media player support
#
# This displays "ARTIST - SONG" if a music is playing.
# Supported players are: spotify, vlc, audacious, xmms2, mplayer, and others.
[mpd]
#instance=spotify
interval=1
signal=13
#markup=none
# OpenVPN support # OpenVPN support
# #
# Support multiple VPN, with colors. # Support multiple VPN, with colors.
@ -166,14 +167,15 @@ signal=13
# The first parameter sets the step (and units to display) # The first parameter sets the step (and units to display)
# The second parameter overrides the mixer selection # The second parameter overrides the mixer selection
# See the script for details. # See the script for details.
[toggle-sink] #[toggle-sink]
interval=once #interval=once
separator=false #separator=false
separator_block_width=0 #separator_block_width=0
[volume] [volume]
#instance=vol #instance=vol
#instance=PCM #instance=PCM
label=vol
interval=once interval=once
signal=10 signal=10
separator=false separator=false

View file

@ -31,9 +31,14 @@ alang=fr,fre,fra
#slang=fr,fre,fra #slang=fr,fre,fra
slang=en,eng,fr,fre,fra slang=en,eng,fr,fre,fra
# Network # Cache
cache=yes cache=yes
demuxer-max-bytes=256MiB cache-pause-wait=5
cache-pause-initial=yes
demuxer-max-bytes=512MiB
demuxer-readahead-secs=20 demuxer-readahead-secs=20
prefetch-playlist=yes
# YTDL
ytdl-format="((bestvideo[vcodec^=av01][height<=?1080][width<=?1920]/bestvideo[vcodec=vp9][height<=?1080][width<=?1920]/bestvideo[height<=?1080][width<=?1920]/bestvideo)+(bestaudio[acodec=opus]/bestaudio[acodec=vorbis]/bestaudio))/best" ytdl-format="((bestvideo[vcodec^=av01][height<=?1080][width<=?1920]/bestvideo[vcodec=vp9][height<=?1080][width<=?1920]/bestvideo[height<=?1080][width<=?1920]/bestvideo)+(bestaudio[acodec=opus]/bestaudio[acodec=vorbis]/bestaudio))/best"
# ytdl-raw-options=ignore-config= # ytdl-raw-options=ignore-config=

View file

@ -180,6 +180,7 @@ ext cbz, has zathura, X, flag f = zathura -- "$@"
mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@" mime ^image/svg, has inkscape, X, flag f = inkscape -- "$@"
mime ^image/svg, has display, X, flag f = display -- "$@" mime ^image/svg, has display, X, flag f = display -- "$@"
mime ^image, has gthumb, X, flag f = gthumb -- "$@"
mime ^image, has viewnior, X, flag f = viewnior -- "$@" mime ^image, has viewnior, X, flag f = viewnior -- "$@"
mime ^image, has imv, X, flag f = imv -- "$@" mime ^image, has imv, X, flag f = imv -- "$@"
mime ^image, has pqiv, X, flag f = pqiv -- "$@" mime ^image, has pqiv, X, flag f = pqiv -- "$@"

View file

@ -11,7 +11,7 @@ else
[[ -z "$origstatus" ]] && origstatus='stop' [[ -z "$origstatus" ]] && origstatus='stop'
fi fi
LONG=30 LONG=15
SHORT=15 SHORT=15
case $BLOCK_BUTTON in case $BLOCK_BUTTON in

View file

@ -1,136 +1,62 @@
#!/bin/bash #!/bin/bash
LONG=25 LENGHT=40
SHORT=10
human_time() { human_time() {
# Prends des secondes
local seconds="$1" local seconds="$1"
if [[ "$seconds" -lt 0 ]] if [[ "$seconds" -lt 0 ]]
then then
# Négatif = pas de temps à afficher
echo "--:--" echo "--:--"
return return
fi fi
# Calcule les minutes
local minutes=$(( $seconds / 60 )) local minutes=$(( $seconds / 60 ))
seconds=$(( $seconds % 60 )) seconds=$(( $seconds % 60 ))
if [[ "$minutes" -ge 90 ]]
# Calcule les heures
local hours=$(( $minutes / 60 ))
minutes=$(( $minutes % 60 ))
if [[ "$hours" -ge 1 ]]
then then
printf "%5s\n" "${minutes}m" # Si on dépasse lheure affiche le temps en heures-minutes
printf "%02dh%02d\n" "$hours" "$minutes"
else else
# Sinon en minutes-secondes
printf "%02d:%02d\n" "$minutes" "$seconds" printf "%02d:%02d\n" "$minutes" "$seconds"
fi fi
return return
} }
if ! systemctl --user is-active mpd &>/dev/null # Boucle principale
while true
do
# Déclaration des variables
declare status
# État du serveur
if ! systemctl --user is-active mpd.service &>/dev/null
then then
origstatus='off' # Traitement particulier pour le cas où le service est coupé
status="off"
else else
origstatus="$(mpc status | sed -n '2p' | grep -Eo '^\[.*\]' | tr -d '[]')" status="$(mpc status | sed -n '2p' | grep -Eo '^\[.*\]' | tr -d '[]')"
[[ -z "$origstatus" ]] && origstatus='stop' [[ -z status ]] && status="stopped"
fi fi
artist="$(mpc -f '%artist%' current)"
title="$(mpc -f '%title%' current)"
name="$(mpc -f '%name%' current)"
file="$(basename "$(mpc -f '%file%' current)")"
album="$(mpc -f '%album%' current)"
case $BLOCK_BUTTON in ( zscroll -b "<b>$artist</b> " "${title:-${file}}" ) &
1) mpc -q prev ;; pid="$!"
2) mpc -q toggle ;;
3) mpc -q next ;;
4) mpc -q volume +2 ;;
5) mpc -q volume -2 ;;
esac
status="<span foreground=\"#6699CC\">"
case $origstatus in
stop ) status="<span foreground=\"#F2777A\">" ;;
paused ) status="<span foreground=\"#FFCC66\">" ;;
playing ) status="<span foreground=\"#99CC99\">" ;;
off ) status="<span foreground=\"#515151\">" ;;
esac
if [[ "$origstatus" != "stop" ]] && [[ "$origstatus" != "off" ]]
then
if [[ ! -f /dev/shm/mpd ]]
then
mpc -f '[[%artist%§]%title%|[%file%]' current > /dev/shm/mpd
fi
song=$(</dev/shm/mpd)
if [[ "${#song}" -gt $LONG ]]
then
scrolling=long
elif [[ "${#song}" -gt $SHORT ]]
then
scrolling=short
else
scrolling=none
fi
if [[ "$scrolling" != "none" ]]
then
scroll="$(</dev/shm/mpd-scroll)"
if [[ -z "${scroll// /}" ]]
then
printf "%-${LONG}s" "$(</dev/shm/mpd)" > /dev/shm/mpd-scroll
song="$(</dev/shm/mpd-scroll)"
else
song="$(</dev/shm/mpd-scroll)"
printf "%-${LONG}s" "${song:1}" > /dev/shm/mpd-scroll
fi
fi
time="$(echo -e 'status\nclose' | nc -U $MPD_HOST | grep time \
| cut -d' ' -f2)"
time_elapsed=$(human_time "${time%:*}")
time_total=$(human_time "${time#*:}")
time_left=$(human_time "$(( ${time#*:} - ${time%:*} ))")
longtime="[$time_elapsed $time_left ${time_total/00:00/--:--}]"
shorttime="$time_elapsed $time_left"
case $scrolling in
long)
longsong="${song} "
shortsong="${song} "
;;
short)
longsong="$(</dev/shm/mpd) "
shortsong="${song} "
;;
none)
longsong="$(</dev/shm/mpd) "
shortsong="$longsong"
;;
esac
longsong="${longsong:0:$LONG}"
shortsong="${shortsong:0:$SHORT}"
longsong="${longsong//&/&amp;}"
shortsong="${shortsong//&/&amp;}"
if [[ "$longsong" =~ § ]]
then
longsong="<u>${longsong/§/</u> }"
elif [[ "$song" =~ § ]]
then
longsong="<u>${longsong}</u>"
fi
if [[ "$shortsong" =~ § ]]
then
shortsong="<u>${shortsong/§/</u> }"
elif [[ "$song" =~ § ]]
then
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
printf "%${LONG}s $status[--:-- --:-- --:--]</span>\n" " "
printf "%${SHORT}s $status--:-- --:--</span>\n" " "
fi
mpc idle &>/dev/null
kill "$pid"
done