Mise à jour du script de notification MPD

This commit is contained in:
Breizh 2024-05-16 16:42:12 +02:00
parent 231feb4c11
commit e810eff72c
7 changed files with 30 additions and 30 deletions

View file

@ -217,7 +217,7 @@ URxvt.keysym.C-equal: resize-font:reset
URxvt.keysym.C-question: resize-font:show URxvt.keysym.C-question: resize-font:show
URxvt.keysym.M-s: searchable-scrollback:start URxvt.keysym.M-s: searchable-scrollback:start
URxvt.resize-font.step: 2 URxvt.resize-font.step: 2
URxvt.refreshRate: 240 URxvt.refreshRate: 60
! Base16 Eighties ! Base16 Eighties
! Scheme: Chris Kempson (http://chriskempson.com) ! Scheme: Chris Kempson (http://chriskempson.com)

View file

@ -371,10 +371,10 @@ exec --no-startup-id urxvtc -name newsboat -e newsboat
exec --no-startup-id redshift-gtk exec --no-startup-id redshift-gtk
exec --no-startup-id nm-applet exec --no-startup-id nm-applet
exec --no-startup-id system-config-printer-applet exec --no-startup-id system-config-printer-applet
exec --no-startup-id sleep 1m && 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
#exec --no-startup-id hp-systray -x #exec --no-startup-id hp-systray -x
exec --no-startup-id sleep 1m && play "$HOME/Musique/WELCOME BACK.wav" exec --no-startup-id sleep 20 && pamixer --set-volume 40 && play "$HOME/Musique/WELCOME BACK.wav"
exec --no-startup-id variety exec --no-startup-id variety
#exec --no-startup-id sleep 5m && qbittorrent #exec --no-startup-id sleep 5m && qbittorrent

View file

@ -201,6 +201,10 @@ interval=60
[bepo] [bepo]
interval=60 interval=60
separator=false
[screen_freq]
interval=once
[beep] [beep]
interval=once interval=once

View file

@ -1,5 +1,6 @@
# Vidéo # Vidéo
profile=gpu-hq profile=gpu-hq
gpu-context=x11vk
scale=ewa_lanczossharp scale=ewa_lanczossharp
cscale=ewa_lanczossharp cscale=ewa_lanczossharp
#video-sync=display-resample #video-sync=display-resample

View file

@ -13,8 +13,8 @@ runtime="${XDG_RUNTIME_DIR}/i3blocks"
case $button in case $button in
1) setxkbmap fr bepo_afnor; echo "bépo" > "$runtime/keyboard";; 1) setxkbmap fr bepo_afnor; echo "bépo" > "$runtime/keyboard";;
#1) xmodmap ~/.Xmodmap; echo "bépo" > "$runtime/keyboard";; #1) xmodmap ~/.Xmodmap; echo "bépo" > "$runtime/keyboard";;
2) setxkbmap fr oss; echo "oss " > "$runtime/keyboard";; 2) setxkbmap fr us; echo "qwer" > "$runtime/keyboard";;
3) setxkbmap fr us; echo "qwer" > "$runtime/keyboard";; 3) setxkbmap fr oss; echo "oss " > "$runtime/keyboard";;
esac esac
} &>/dev/null } &>/dev/null
cat "$runtime/keyboard" cat "$runtime/keyboard"

View file

@ -4,7 +4,8 @@ export MPD_HOST="$HOME/.mpd/socket"
DUNST_ID=$(sum <<<"mpd" | cut -d' ' -f1) DUNST_ID=$(sum <<<"mpd" | cut -d' ' -f1)
# Déclaration des variables globales # Déclaration des variables globales
declare -- cursong prevsong declare -- prevfile
declare -a -- infos
# Tant que le service MPD fonctionne # Tant que le service MPD fonctionne
while systemctl --user is-active mpd.service &>/dev/null while systemctl --user is-active mpd.service &>/dev/null
@ -12,24 +13,17 @@ do
# Toutes les 5 secondes, ou dès que le morceau se termine # Toutes les 5 secondes, ou dès que le morceau se termine
timeout 5 mpc -w current timeout 5 mpc -w current
prevsong="$cursong" prevfile="${infos[3]}"
cursong="$(mpc -f '[[%artist%\n|%name%\n]%title%[\n%album%]]|[%file%]' current)" mapfile -t infos < <(mpc -f '[%artist%|%name%]\n%title%\n%album%\n%file%\n%time%' current)
# Si le morceau a changé depuis la dernière vérification # Si le morceau a changé depuis la dernière vérification
if [[ "$cursong" != "$prevsong" && "$prevsong" != "<i>Arrêt</i>" ]] if [[ "${infos[3]}" != "$prevfile" && "$title" != "<i>Arrêt</i>" ]]
then then
# Extractions des informations depuis la chaîne récupérée plus artist="${infos[0]}"
# tôt, vers un format plus lisible. title="${infos[1]:-${infos[3]}}"
artist="$(sed -n 1p <<<"$cursong")" album="${infos[2]}"
title="$(sed -n 2p <<<"$cursong")" length="$(( ${infos[4]%%:*} * 60 + ${infos[4]##*:} ))"
album="$(sed -n 3p <<<"$cursong")"
# Petit trick : si le titre sest retrouvé sur la première
# ligne parce quil ny a pas dartiste renseigné, on corrige
# le contenu des variables (pas forcément fiable, mais
# chez moi ça marche™).
[[ -z "$title" ]] && title="$artist" && artist=""
# Si on obtiens un chemin absolu, on naffiche que le nom, pas # Si on obtiens un chemin absolu, on naffiche que le nom, pas
# le chemin. # le chemin.
@ -37,21 +31,22 @@ do
# Si aucune information nest retournée, cest que la lecture # Si aucune information nest retournée, cest que la lecture
# sest arrêtée. # sest arrêtée.
if [[ -z "$cursong" ]] if [[ "${#infos[@]}" -eq 0 ]]
then then
cursong="<i>Arrêt</i>" title="<i>Arrêt</i>"
unset artist title album unset artist title album length
fi fi
# Notification du morceau # Notification du morceau
dunstify -r "$DUNST_ID" "MPD" "$cursong" dunstify -r "$DUNST_ID" "MPD" "${artist:+${artist}$'\n'}${title}"$'\n'"${album}"
# Ajout au scrobbler Pleroma # Ajout au scrobbler Pleroma
# curl -s -X POST -u "breizh:$(pass show Web/pleroma.breizh.pm)" \ curl -s -X POST -u "breizh:$(pass show Web/pleroma.breizh.pm)" \
# --data-urlencode "title=${title}" \ --data-urlencode "title=${title}" \
# --data-urlencode "artist=${artist}" \ --data-urlencode "artist=${artist}" \
# --data-urlencode "album=${album}" \ --data-urlencode "album=${album}" \
# https://pleroma.breizh.pm/api/v1/pleroma/scrobble &>/dev/null --data-urlencode "length=${length}" \
https://pleroma.breizh.pm/api/v1/pleroma/scrobble &>/dev/null
fi fi
done done

View file

@ -35,6 +35,6 @@ fi
urxvtd -q -f -o urxvtd -q -f -o
[ -f $HOME/.fehbg ] && $HOME/.fehbg [ -f $HOME/.fehbg ] && $HOME/.fehbg
[ -f $HOME/.screenlayout/home.sh ] && $HOME/.screenlayout/home.sh #[ -f $HOME/.screenlayout/home.sh ] && $HOME/.screenlayout/home.sh
exec i3 #--shmlog-size=26214400 exec i3 #--shmlog-size=26214400