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.M-s: searchable-scrollback:start
URxvt.resize-font.step: 2
URxvt.refreshRate: 240
URxvt.refreshRate: 60
! Base16 Eighties
! 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 nm-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 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 sleep 5m && qbittorrent

View file

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

View file

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

View file

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

View file

@ -4,7 +4,8 @@ export MPD_HOST="$HOME/.mpd/socket"
DUNST_ID=$(sum <<<"mpd" | cut -d' ' -f1)
# Déclaration des variables globales
declare -- cursong prevsong
declare -- prevfile
declare -a -- infos
# Tant que le service MPD fonctionne
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
timeout 5 mpc -w current
prevsong="$cursong"
cursong="$(mpc -f '[[%artist%\n|%name%\n]%title%[\n%album%]]|[%file%]' current)"
prevfile="${infos[3]}"
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
if [[ "$cursong" != "$prevsong" && "$prevsong" != "<i>Arrêt</i>" ]]
if [[ "${infos[3]}" != "$prevfile" && "$title" != "<i>Arrêt</i>" ]]
then
# Extractions des informations depuis la chaîne récupérée plus
# tôt, vers un format plus lisible.
artist="$(sed -n 1p <<<"$cursong")"
title="$(sed -n 2p <<<"$cursong")"
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=""
artist="${infos[0]}"
title="${infos[1]:-${infos[3]}}"
album="${infos[2]}"
length="$(( ${infos[4]%%:*} * 60 + ${infos[4]##*:} ))"
# Si on obtiens un chemin absolu, on naffiche que le nom, pas
# le chemin.
@ -37,21 +31,22 @@ do
# Si aucune information nest retournée, cest que la lecture
# sest arrêtée.
if [[ -z "$cursong" ]]
if [[ "${#infos[@]}" -eq 0 ]]
then
cursong="<i>Arrêt</i>"
unset artist title album
title="<i>Arrêt</i>"
unset artist title album length
fi
# Notification du morceau
dunstify -r "$DUNST_ID" "MPD" "$cursong"
dunstify -r "$DUNST_ID" "MPD" "${artist:+${artist}$'\n'}${title}"$'\n'"${album}"
# Ajout au scrobbler Pleroma
# curl -s -X POST -u "breizh:$(pass show Web/pleroma.breizh.pm)" \
# --data-urlencode "title=${title}" \
# --data-urlencode "artist=${artist}" \
# --data-urlencode "album=${album}" \
# https://pleroma.breizh.pm/api/v1/pleroma/scrobble &>/dev/null
curl -s -X POST -u "breizh:$(pass show Web/pleroma.breizh.pm)" \
--data-urlencode "title=${title}" \
--data-urlencode "artist=${artist}" \
--data-urlencode "album=${album}" \
--data-urlencode "length=${length}" \
https://pleroma.breizh.pm/api/v1/pleroma/scrobble &>/dev/null
fi
done

View file

@ -35,6 +35,6 @@ fi
urxvtd -q -f -o
[ -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