~hnaguski/aart

163eec894b2dd09a895ac9cc99c910a667d89fda — Henry Naguski 1 year, 10 months ago e4089de
close image viewer on script close, remove useless variable definition, and make output a bit nicer
1 files changed, 16 insertions(+), 7 deletions(-)

M aart
M aart => aart +16 -7
@@ 3,7 3,6 @@
music_dir=$(xdg-user-dir MUSIC)

extract_art() {

	current_path=$music_dir/$1

	# use ffmpeg to extract album art embedded in music files. copies the same


@@ 64,7 63,11 @@ set_art() {
	printf "finding art for %s\n" "$(mpc current)"
	extract_art "$1" || copy_art "$1" || no_art

	cp -f "$art" art
	# copy the art to the file that's open in the image viewer
	cp --remove-destination "$art" art

	# make output a bit easier to read
	printf "\n"
}

first_start() {


@@ 80,15 83,21 @@ first_start() {

	set_art "$file"

	# open sxiv on the art
	sxiv -b art &
	# open image viewer on the art and store the pid
	sxiv -b art & viewer_pid=$!
}

close_script() {
	# kill the viewer and exit
	kill $viewer_pid
	exit 0
}

first_start

trap close_script INT

while true;
do
	new_file=$(mpc -q current --wait -f %file%)
	
	set_art "$new_file"
	set_art "$(mpc -q current --wait -f %file%)"
done