#!/bin/bash # create cached album list source $HOME/.config/clerk/config new_db="$(mpc stats | grep Updated | sed 's/ //g')" if [[ "$change_db" == "$new_db" ]]; then if [[ -f $HOME/.config/clerk/album.cache && -f $HOME/.config/clerk/tracks.cache && -f $HOME/.config/clerk/last.cache ]]; then : else notify-send "clerk" "Creating caches" mppc albumcache mppc trackcache last_temp_cur=$(export seperator="$seperator"; mppc listall --format "{last-modified}$seperator{date}$seperator{$mpd_artist}$seperator{album}" | sort -r | awk -F "$seperator" '{ print $2 ENVIRON["seperator"] $3 ENVIRON["seperator"] $4 }' | awk '!x[$0]++') echo "$last_temp_cur" > $HOME/.config/clerk/last.cache fi else notify-send "clerk" "Updating caches" sed -i "s/change_db=".*"/change_db=""$new_db""/" $HOME/.config/clerk/config export seperator="$seperator"; mppc albumcache export seperator="$seperator"; mppc trackcache last_temp_cur=$(export seperator="$seperator"; mppc listall --format "{last-modified}$seperator{date}$seperator{$mpd_artist}$seperator{album}" | sort -r | awk -F "$seperator" '{ print $2 ENVIRON["seperator"] $3 ENVIRON["seperator"] $4 }' | awk '!x[$0]++') rm -f $HOME/.config/clerk/last.cache echo "$last_temp_cur" > $HOME/.config/clerk/last.cache fi