summaryrefslogtreecommitdiff
path: root/scripts/.local/bin/on_song_change
blob: 243d706aa3a5cd5f011fbbfdc0b993d0262b2a29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash

# https://gist.github.com/vlevit/4588882
MUSIC_DIR="$HOME/audio/music"
album="$(mpc --format %album% current)"
file="$(mpc --format %file% current)"
album_dir="${file%/*}"
[[ -z "$album_dir" ]] && exit 1
album_dir="$MUSIC_DIR/$album_dir"

covers="$(find "$album_dir" -type d -exec find {} -maxdepth 1 -type f -iregex ".*/.*\(${album}\|cover\|folder\|artwork\|front\).*[.]\(jpe?g\|png\|gif\|bmp\)" \; )"
cover="$(echo -n "$covers" | head -n1)"

cp -f "$cover" /tmp/mpd.cover