Skip to content

Instantly share code, notes, and snippets.

@ardek66
Last active September 29, 2022 21:55
Show Gist options
  • Save ardek66/f12d1e593123a07b45df9c26f4e33201 to your computer and use it in GitHub Desktop.
Save ardek66/f12d1e593123a07b45df9c26f4e33201 to your computer and use it in GitHub Desktop.
#!/bin/bash
MUSIC_DIR=/home/idf/fisiere/Muzica/
TMP_COVER=/tmp/cover.png
DEFAULT_COVER=/home/idf/.cover.png
mpc current -f "%file%\n%artist% - %title%\nAlbum: %album%\nDuration: %time%\nPosition in playlist: %position%" |
(mapfile -t song
cover=$TMP_COVER
dir="$MUSIC_DIR/${song[0]}"
while [ ! -d "$dir" ]; do dir="${dir%/*}"; done
for fcover in "$dir"/{{c,C}over.{jpg,png},{Cover,Scan}{,s}/CD{,1}.{png,jpg}}; do
if [ -f "$fcover" ]; then cover="$fcover"; break; fi
done
if [ "$cover" == "$TMP_COVER" ]; then
if ! ffmpeg -hide_banner -loglevel panic -i "$MUSIC_DIR/${song[0]}" -an -vcodec copy "$TMP_COVER"; then
cover=$DEFAULT_COVER
fi
fi
~/notifishower/notifishower --background 282828 --border d79921 --border.width 3 --font "IBMPlexSans-Regular/12" \
-x "center+0" -y 28 -w ">=500"\
--title.text "${song[1]}" --title.font "IBMPlexSans-Bold/12" --title.color 98971a \
--album.text "${song[2]}" --album.color b8bb26 \
--duration.text "${song[3]}" --duration.color ebdbb2 \
--position.text "${song[4]}" --position.color ebdbb2 \
--cover.image "$cover" \
--timeout 5 \
--format "([cover:96]-[title album ~duration position~])")
rm -f "$TMP_COVER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment