From a24c1385b6e6cca2159ae6c0bbefdf711501a5d6 Mon Sep 17 00:00:00 2001 From: Rasmus Steinke Date: Sun, 30 Aug 2015 12:14:38 +0200 Subject: make updating caches nicer; properly sort latest cache --- clerk | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/clerk b/clerk index 9b8fed9..9ddad08 100755 --- a/clerk +++ b/clerk @@ -81,6 +81,7 @@ fix_date_format() { updateCache () { + notify-send "clerk" "updating cache files" cd $HOME/.config/clerk rm -f *.cache mpc --format '[%mtime%\t%albumartist%|%artist%] - (%date%) - %album%' \ @@ -88,12 +89,12 @@ updateCache () { | grep -v '^ — ' \ | grep -v ' — $' \ | uniq \ - | fix_date_format 1 '%Y-%m-%d' \ + | fix_date_format 1 '%Y-%m-%d-%H:%M:%S' \ | sort -u \ | sort -nr \ | awk '{for (i=2; i $HOME/.config/clerk/latest.cache + | sed 's,^\([^\t]*\t[^\t]\{40\}\)[^\t]*,\1,' | column -o ' ' -s $'\t' -t | uniq > $HOME/.config/clerk/latest.cache mpc --format '[%albumartist%|%artist%]\t(%date%) - %album%' \ search filename '' \ | grep -v '^ - ' \ @@ -108,21 +109,18 @@ updateCache () { | uniq \ | sed 's,^\([^\t]\{40\}\)[^\t]*,\1…,' | column -o $'\t' -s $'\t' -t \ > $HOME/.config/clerk/tracks.cache + notify-send "clerk" "finished updating cache files" } # check if clerk_helper process is running. if it isn't update cache files, if # needed -if [[ $(ps x| grep clerk_helper | head -1 | grep -v 'grep') ]]; then +date=$(mpc stats | grep 'DB Updated: ') +file="$HOME/.config/clerk/.lastupdate" +if [ "$(< $file)" = "$date" ] && [ -f "$file" ] ; then : else - date=$(mpc stats | grep 'DB Updated: ') - file="$HOME/.config/clerk/.lastupdate" - if [ "$(< $file)" = "$date" ] && [ -f "$file" ] ; then - : - else - updateCache - echo "${date}" > "${file}" - fi + updateCache + echo "${date}" > "${file}" fi export separator="$separator" -- cgit v1.2.3-24-g4f1b