Having purged myself a while ago from the bloatness of conky I now had no album art visible anywhere.
Decided to make something out of the cmus's status_display_program, so I made this little script.
It downloads (glyrc) backdrop (if one does now already exist) of the artist currently playing
(and album art if needed) and uses feh to make a nice wallpaper automanically.
I first tried setting album art tiled as background, but that was too psychedelic even for me.
So, heres a taste (sorry for quite speedy delivery): https://u.teknik.io/h0C2Pn.webm
Dependencies: glyrc, feh and imagemagick. (I tried to compensate for the lack of bloat with conky gone)
And here's the script itself:
Code: Select all
#!/bin/bash
# By tenkainen
# Makes the wallpaper from backdrops of artist currently playing, uses glyrc for it.
# Also fetches albumart if needed. Albumart in the same folder as track playing is used.
# --- This script only makes sense, if you use separate folder for different albums ---
# Other paths for albumart needs to be hacked together themself by the nutter using it and this script.
# Folder for backdrop can be adjusted in variables.
# Please, fill in the user defined variable below!
if [[ -z $(which glyrc) || -z $(which mogrify) || -z $(which feh) ]]
then
echo -e "\e[31mGlyrc, imagemagick and feh needed to operate, smoothly.\e[00m"
echo -e "\e[33mOn Debian: (sudo) apt install glyrc imagemagick feh\e[00m"
exit 0
fi
# User defined variables
tmpdir="~/tmp"
genericbd="$tmpdir/generic_backdrop.jpg" # Used for albums glyrc can't find backdrop for
albumart="Folder.jpg"
player="cmus"
resolution="1920x1200"
wplocation="~/"
bdfolder="../" # ../ used the logic of Music/Artist/Artist-Album1/tracks.mp3 etc, so only one backdrop per artist
# ./ or empty can be used for backdrop.jpg for every album. Wasteful for large music collections.
# The actual existence of the folder in question is never checked. As not to make empty folders in some cases.
# ---------- ONLY CMUS SUPPORTED ATM, write your own below, if you really want -------------------
# Needed from the player: a means to get artist and album of the track playing and path to the actual file
# On Cmus, you can assign this script to the status_display_program variable
# so it updates the wallpaper automatically when playing music
if [[ "$player" == "cmus" && ! -z $(pgrep cmus) ]]
then
artist=$(cmus-remote -Q | grep "tag artist" | cut -d ' ' -f 3-)
album=$(cmus-remote -Q | grep "tag album" | cut -d ' ' -f 3-)
npfile=$(cmus-remote -Q | grep file | cut -d ' ' -f 2-)
else
echo -e "\e[31mNo compatible players found active.\e[00m"
echo -e "\e[33mAlso, only Cmus supported, for now.\e[00m"
exit 0
fi
npdir=$(dirname "${npfile}")
edartist=$(cat "$tmpdir"/npartist.txt | head -n 1)
edalbum=$(cat "$tmpdir"/npalbum.txt | head -n 1)
echo "$artist" > "$tmpdir"/npartist.txt
echo "$album" > "$tmpdir"/npalbum.txt
if [[ ! -a "$npdir/$bdfolder/backdrop.jpg" ]]
then
glyrc backdrops -a "$artist" --write "$npdir/$bdfolder/backdrop.jpg"
fi
if [[ ! -a "$npdir/$albumart" ]]
then
glyrc cover -a "$artist" -b "$album" --write "$npdir/$albumart"
fi
if [[ ! "$album" == "$edalbum" ]]
then
if [[ -a "$npdir/$bdfolder/backdrop.jpg" ]]
then
bg_kuva="$npdir/$bdfolder/backdrop.jpg"
else
bg_kuva="$genericbd"
fi
fg_kuva="$npdir/$albumart"
convert "$fg_kuva" -alpha set -channel A -evaluate set 80% "$tmpdir"/etu.png
mogrify -resize $resolution! "$bg_kuva"
composite -gravity SouthEast -geometry +10+10 "$tmpdir"/etu.png "$bg_kuva" "$wplocation"/wallpaper.png
DISPLAY=:0.0; feh --bg-scale "$wplocation"/wallpaper.png
rm "$tmpdir"/etu.png
fi