summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2015-08-30 01:20:39 +0200
committerRasmus Steinke <rasi@xssn.at>2015-08-30 01:20:39 +0200
commit605014a96f3f38f04673b601aa1516f5c8cd9a22 (patch)
treeaee55ccf0334296d3f416d19fc6a86b3cdf71f1a
parentb793d155f8e80a579c44fb31a14e867d1f4364db (diff)
downloadperl-app-clerk-605014a96f3f38f04673b601aa1516f5c8cd9a22.tar.gz
perl-app-clerk-605014a96f3f38f04673b601aa1516f5c8cd9a22.tar.xz
auto update
-rwxr-xr-xclerk32
-rwxr-xr-xclerk_helper2
2 files changed, 21 insertions, 13 deletions
diff --git a/clerk b/clerk
index 1c4a44f..6ec9e71 100755
--- a/clerk
+++ b/clerk
@@ -41,12 +41,31 @@ elif [[ $scrobbler == mpdscribble ]]; then
export scrobbler_kill="mpdscribble"
fi
+updateCache () {
+ cd $HOME/.config/clerk
+ rm -f *.cache
+ clerk_helper createcache
+ cat tracks.cache | sed 's,^\([^\t]*\t[^\t]\{40\}\)[^\t]*,\1,' | column -o ' ' -s $'\t' -t > tracks.cache.new
+ mv tracks.cache.new tracks.cache
+ cat latest.cache | column -o $'\t' -s $'\t' -t > latest.cache.new
+ mv latest.cache.new latest.cache
+ cat albums.cache | column -o $'\t' -s $'\t' -t > albums.cache.new
+ mv albums.cache.new albums.cache
+}
+
# 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
:
else
- clerk_helper update &
+ date=$(mpc stats | grep 'DB Updated: ')
+ file="$HOME/.config/clerk/.lastupdate"
+ if [ "$(< $file)" = "$date" ] && [ -f "$file" ] ; then
+ :
+ else
+ updateCache
+ echo "${date}" > "${file}"
+ fi
fi
export separator="$separator"
@@ -76,17 +95,6 @@ sed=$([[ "$OSTYPE" == "darwin"* ]] && echo 'gsed' || echo 'sed')
shuf=$([[ "$OSTYPE" == "darwin"* ]] && echo 'gshuf' || echo 'shuf')
tac=$([[ "$OSTYPE" == "darwin"* ]] && echo 'gtac' || echo 'tac')
-updateCache() {
- cd $HOME/.config/clerk
- rm -f *.cache
- clerk_helper createcache
- cat tracks.cache | sed 's,^\([^\t]\{40\}\)[^\t]*,\1…,' | column -o $'\t' -s $'\t' -t > tracks.cache.new
- mv tracks.cache.new tracks.cache
- cat latest.cache | column -o $'\t' -s $'\t' -t > latest.cache.new
- mv latest.cache.new latest.cache
- cat albums.cache | column -o $'\t' -s $'\t' -t > albums.cache.new
- mv albums.cache.new albums.cache
-}
# main Menu
dplayPrompt () {
diff --git a/clerk_helper b/clerk_helper
index a465c15..d48d2a8 100755
--- a/clerk_helper
+++ b/clerk_helper
@@ -120,7 +120,7 @@ def createCache(args):
taglist = ['date', 'artist', 'albumartist', 'album', 'track', 'title', 'file']
track.update([(k, reduceToFstElm(v)) for (k, v) in track.items() if k in taglist])
- tracklist.append(track['track']+" "+track['title']+"\tby "+track['artist']+" on "+track['album']+" ("+track['date']+")\t"+track['file'])
+ tracklist.append(track['track']+"\t"+track['title']+"\tby "+track['artist']+" on "+track['album']+" ("+track['date']+")\t"+track['file'])
#
with open(os.getenv('HOME')+'/.config/clerk/tracks.cache', "w") as cache_file:
for track in tracklist: