From b4fe385d4f9891147a75c13994ecce298b0a4e3d Mon Sep 17 00:00:00 2001 From: Breizh Date: Sat, 5 Jun 2021 22:49:18 +0200 Subject: [PATCH] Tentative renouvellement block MPD --- .config/gtk-3.0/settings.ini.bak | 6 +- .config/i3/config | 3 +- .config/i3blocks/config | 30 ++++--- .config/mpv/mpv.conf | 9 +- .config/ranger/rifle.conf | 1 + .i3blocks/mpd | 12 +-- .i3blocks/mpd.new | 146 ++++++++----------------------- 7 files changed, 70 insertions(+), 137 deletions(-) diff --git a/.config/gtk-3.0/settings.ini.bak b/.config/gtk-3.0/settings.ini.bak index b6d5326..3a8c398 100644 --- a/.config/gtk-3.0/settings.ini.bak +++ b/.config/gtk-3.0/settings.ini.bak @@ -1,8 +1,8 @@ [Settings] -gtk-application-prefer-dark-theme=false +gtk-application-prefer-dark-theme=true gtk-theme-name=Vertex-Dark -gtk-icon-theme-name=Vertex-Icons -gtk-font-name=IBM Plex Sans 11 +gtk-icon-theme-name=Adwaita +gtk-font-name=IBM Plex Sans 10 gtk-button-images=1 gtk-menu-images=1 gtk-enable-event-sounds=1 diff --git a/.config/i3/config b/.config/i3/config index e25d6d4..8f15739 100644 --- a/.config/i3/config +++ b/.config/i3/config @@ -353,7 +353,7 @@ bindsym $mod+9 exec --no-startup-id xscreensaver-command -activate # Autostart applications ## 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/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/conkyrc2" 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 xinput --disable "AlpsPS/2 ALPS DualPoint TouchPad" 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 steam-native -silent -noverifyfiles -language french #exec --no-startup-id SVPManager diff --git a/.config/i3blocks/config b/.config/i3blocks/config index f104da3..47dfa99 100644 --- a/.config/i3blocks/config +++ b/.config/i3blocks/config @@ -31,6 +31,17 @@ markup=pango #command=echo $(xdotool getactivewindow getwindowname) #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 # # The script may be called with -w and -c switches to specify thresholds, @@ -145,16 +156,6 @@ interval=600 #interval=10 #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 # # Support multiple VPN, with colors. @@ -166,14 +167,15 @@ signal=13 # The first parameter sets the step (and units to display) # The second parameter overrides the mixer selection # See the script for details. -[toggle-sink] -interval=once -separator=false -separator_block_width=0 +#[toggle-sink] +#interval=once +#separator=false +#separator_block_width=0 [volume] #instance=vol #instance=PCM +label=vol interval=once signal=10 separator=false diff --git a/.config/mpv/mpv.conf b/.config/mpv/mpv.conf index c06c022..4f50e02 100644 --- a/.config/mpv/mpv.conf +++ b/.config/mpv/mpv.conf @@ -31,9 +31,14 @@ alang=fr,fre,fra #slang=fr,fre,fra slang=en,eng,fr,fre,fra -# Network +# Cache cache=yes -demuxer-max-bytes=256MiB +cache-pause-wait=5 +cache-pause-initial=yes +demuxer-max-bytes=512MiB 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-raw-options=ignore-config= diff --git a/.config/ranger/rifle.conf b/.config/ranger/rifle.conf index 45e2bf9..48b848e 100644 --- a/.config/ranger/rifle.conf +++ b/.config/ranger/rifle.conf @@ -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 display, X, flag f = display -- "$@" +mime ^image, has gthumb, X, flag f = gthumb -- "$@" mime ^image, has viewnior, X, flag f = viewnior -- "$@" mime ^image, has imv, X, flag f = imv -- "$@" mime ^image, has pqiv, X, flag f = pqiv -- "$@" diff --git a/.i3blocks/mpd b/.i3blocks/mpd index 957d200..e89a3c4 100755 --- a/.i3blocks/mpd +++ b/.i3blocks/mpd @@ -11,7 +11,7 @@ else [[ -z "$origstatus" ]] && origstatus='stop' fi -LONG=30 +LONG=15 SHORT=15 case $BLOCK_BUTTON in @@ -95,15 +95,15 @@ then case $scrolling in long) - longsong="${song} " - shortsong="${song} " + longsong="${song}" + shortsong="${song}" ;; short) - longsong="$(<${runtime}/mpd) " - shortsong="${song} " + longsong="$(<${runtime}/mpd)" + shortsong="${song}" ;; none) - longsong="$(<${runtime}/mpd) " + longsong="$(<${runtime}/mpd)" shortsong="$longsong" ;; esac diff --git a/.i3blocks/mpd.new b/.i3blocks/mpd.new index 3267a24..e499e8a 100755 --- a/.i3blocks/mpd.new +++ b/.i3blocks/mpd.new @@ -1,136 +1,62 @@ #!/bin/bash -LONG=25 -SHORT=10 +LENGHT=40 human_time() { + # Prends des secondes local seconds="$1" + if [[ "$seconds" -lt 0 ]] then + # Négatif = pas de temps à afficher echo "--:--" return fi + + # Calcule les minutes local minutes=$(( $seconds / 60 )) seconds=$(( $seconds % 60 )) - if [[ "$minutes" -ge 90 ]] + + # Calcule les heures + local hours=$(( $minutes / 60 )) + minutes=$(( $minutes % 60 )) + + if [[ "$hours" -ge 1 ]] then - printf "%5s\n" "${minutes}m" + # Si on dépasse l’heure affiche le temps en heures-minutes + printf "%02dh%02d\n" "$hours" "$minutes" else + # Sinon en minutes-secondes printf "%02d:%02d\n" "$minutes" "$seconds" fi return } -if ! systemctl --user is-active mpd &>/dev/null -then - origstatus='off' -else - origstatus="$(mpc status | sed -n '2p' | grep -Eo '^\[.*\]' | tr -d '[]')" - [[ -z "$origstatus" ]] && origstatus='stop' -fi - +# Boucle principale +while true +do + # Déclaration des variables + declare status -case $BLOCK_BUTTON in - 1) mpc -q prev ;; - 2) mpc -q toggle ;; - 3) mpc -q next ;; - 4) mpc -q volume +2 ;; - 5) mpc -q volume -2 ;; -esac - -status="" -case $origstatus in - stop ) status="" ;; - paused ) status="" ;; - playing ) status="" ;; - off ) status="" ;; -esac - -if [[ "$origstatus" != "stop" ]] && [[ "$origstatus" != "off" ]] -then - if [[ ! -f /dev/shm/mpd ]] + # État du serveur + if ! systemctl --user is-active mpd.service &>/dev/null then - mpc -f '[[%artist%§]%title%|[%file%]' current > /dev/shm/mpd - fi - - song=$( /dev/shm/mpd-scroll - song="$( /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="$(" - echo "${shortsong} $status$shorttime" -else - [[ -f /dev/shm/mpd ]] && rm /dev/shm/mpd - [[ -f /dev/shm/mpd-scroll ]] && rm /dev/shm/mpd-scroll - printf "%${LONG}s $status[--:-- --:-- --:--]\n" " " - printf "%${SHORT}s $status--:-- --:--\n" " " -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)" + ( zscroll -b "$artist " "${title:-${file}}" ) & + pid="$!" + mpc idle &>/dev/null + kill "$pid" +done