~hnaguski/aart

e4089defa610e59cc64564201c10339d8ecc7acf — Henry Naguski 2 years ago 3cfad84
give set_art more responsibility and remove the annoying if statement in the main loop
1 files changed, 8 insertions(+), 16 deletions(-)

M aart
M aart => aart +8 -16
@@ 60,6 60,10 @@ no_art() {
}

set_art() {
	# attempt to get the album art in various ways
	printf "finding art for %s\n" "$(mpc current)"
	extract_art "$1" || copy_art "$1" || no_art

	cp -f "$art" art
}



@@ 68,18 72,13 @@ first_start() {
	pgrep mpd >/dev/null || exit 1

	# check status of mpd, if it's stopped then wait for mpd to start playing a
	# song
	# maybe only check for playing, I leave mpd paused quite often
	# song maybe only check for playing, I leave mpd paused quite often
	mpc status | grep -o "playing\|paused" > /dev/null || file=$(mpc -q current --wait -f %file%)

	# get current song's filename relative to mpd's music directory
	file=$(mpc current -f %file%)
	# attempt to get the album art in various ways
	printf "finding art for %s\n" "$(mpc current)"
	extract_art "$file" || copy_art "$file" || no_art

	# set the art
	set_art $art
	set_art "$file"

	# open sxiv on the art
	sxiv -b art &


@@ 89,14 88,7 @@ first_start

while true;
do
	file=$(mpc current -f %file%)

	new_file=$(mpc -q current --wait -f %file%)

	if [ "$file" != "$new_file" ]
	then
		printf "finding art for %s\n" "$(mpc current)"
		extract_art	"$new_file" || copy_art "$new_file" || no_art
		set_art $art
	fi
	
	set_art "$new_file"
done