summaryrefslogtreecommitdiffstats
path: root/clerk
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2015-09-02 05:33:07 +0200
committerRasmus Steinke <rasi@xssn.at>2015-09-02 05:33:07 +0200
commit2e572be35844bfc7f454fd4b6de214e45e00d25d (patch)
tree1f93c8f9b83f8fc1f9f2ff02aedd23d08fa8e2e8 /clerk
parente9f4fcd84ee0eb24a78f80e2e785a2683b343d27 (diff)
downloadperl-app-clerk-2e572be35844bfc7f454fd4b6de214e45e00d25d.tar.gz
perl-app-clerk-2e572be35844bfc7f454fd4b6de214e45e00d25d.tar.xz
have proper tables; add config options to define columns width
Diffstat (limited to 'clerk')
-rwxr-xr-xclerk55
1 files changed, 24 insertions, 31 deletions
diff --git a/clerk b/clerk
index 670bf87..c42230f 100755
--- a/clerk
+++ b/clerk
@@ -81,36 +81,34 @@ fix_date_format() {
updateCache () {
+ tracklist="{ printf \"%.${track_width}s\t%.${title_width}s\t%.${artist_width}s\t%.${date_width}s\t%.${album_width}s\t%.500s\n\", \$1, \$2, \$3, \$4, \$5, \$6, \$7, \$8 }"
+ albumlist="{ printf \"%.${artist_width}s\t%.${date_width}s\t%.${album_width}s\n\", \$1, \$2, \$3 }"
notify-send "clerk" "updating cache files"
cd $HOME/.config/clerk
rm -f *.cache
- mpc --format '[%mtime%\t%albumartist%|%artist%] — (%date%) — %album%' \
+ mpc --format '%mtime%\t[%albumartist%|%artist%] — (%date%) — %album%' \
search filename '' \
- | grep -v '^ — ' \
- | grep -v ' — $' \
- | uniq \
| fix_date_format 1 '%Y-%m-%d-%H:%M:%S' \
- | sort -u \
| sort -nr \
| awk '{for (i=2; i<NF; i++) printf $i " "; print $NF}' \
- | awk -F ' — ' '{ print $1 "\t" $2 " — " $3 }' \
+ | uniq \
+ | awk -F ' — ' '{ print $1 "\t" $2 "\t" $3 }' \
+ | awk -F '\t' "$albumlist" \
| column -o $'\t' -s $'\t' -t | uniq > $HOME/.config/clerk/latest.cache
# | sed 's,^\([^\t]*\t[^\t]\{40\}\)[^\t]*,\1,' | column -o $'\t' -s $'\t' -t | uniq > $HOME/.config/clerk/latest.cache
- mpc --format '[%albumartist%|%artist%]\t(%date%) — %album%' \
+ mpc --format '[%albumartist%|%artist%]\t(%date%)\t%album%' \
search filename '' \
- | grep -v '^ — ' \
- | grep -v ' — $' \
| sort \
| uniq \
+ | awk -F '\t' "$albumlist" \
| column -o $'\t' -s $'\t' -t > $HOME/.config/clerk/albums.cache
- mpc --format '[[%title%\t[(by %artist%[ on %album%])]]|[%file%]]\t%file%' \
+ mpc --format '%track%\t%title%\t%artist%\t(%date%)\t%album%\t%file%' \
search filename '' \
- | grep -v '^ — ' \
- | grep -v ' — $' \
- | uniq \
- | sed 's,^\([^\t]\{40\}\)[^\t]*,\1…,' | column -o $'\t' -s $'\t' -t \
+ | awk -F '\t' "$tracklist" \
+ | column -s $'\t' -o $'\t' -t \
> $HOME/.config/clerk/tracks.cache
notify-send "clerk" "finished updating cache files"
+# | awk -F '\t' '{ printf "%.2s\t%.40s\t%.40s\t%.200s\t%.500s\n", $1, $2, $3, $4, $5, $6 }' \
}
date=$(mpc stats | grep 'DB Updated: ')
@@ -614,8 +612,9 @@ HELP="<span color='$help_color'>${line1}
${line2}</span>"
songs () {
- mpc --format '%position%\t\t%track%\t%title%\t(by %artist% on %album% (%date%))' playlist \
- | sed 's,^\([^\t]\{40\}\)[^\t]*,\1…,' \
+ tracklist="{ printf \"%.4s\t%.${track_width}s\t%.${title_width}s\t%.${artist_width}s\t%.${date_width}s\t%.${album_width}s\n\", \$1, \$2, \$3, \$4, \$5, \$6, \$7, \$8 }"
+ mpc --format '%position%\t%track%\t%title%\t%artist%\t(%date%)\t%album%' playlist \
+ | awk -F '\t' "$tracklist" \
| column -o ' ' -s $'\t' -t
}
@@ -990,13 +989,10 @@ TRACK_TEMP=$((echo -e "0 Return to Browse Menu\n---"; cat $HOME/.config/clerk/l
artist=$(echo -en "$TRACK" \
| awk -F '\t' '{ print $1 }' \
| sed -e 's/[[:space:]]*$//')
- group2=$(echo -en "$TRACK" \
- | awk -F '\t' '{ print $2 }' \
- | sed -e 's/[[:space:]]*$//')
- album=$(echo "$group2" \
- | awk -F " — " '{print $2}')
- date=$(echo "$group2" \
- | awk -F " — " '{print $1}' \
+ album=$(echo "$TRACK" \
+ | awk -F "\t" '{print $3}')
+ date=$(echo "$TRACK" \
+ | awk -F "\t" '{print $2}' \
| awk '{print substr($0, 2, length($0) - 2)}')
echo -e "${TRACK}\nartist: ${artist}\nalbum: ${album}\ndate: ${date}"
@@ -1074,13 +1070,10 @@ TRACK_TEMP=$((echo -e "0 Return to Browse Menu\n---"; cat $HOME/.config/clerk/a
artist=$(echo -en "$TRACK" \
| awk -F '\t' '{print $1}' \
| sed -e 's/[[:space:]]*$//')
- group2=$(echo -en "$TRACK" \
- | awk -F '\t' '{print $2}' \
- | sed -e 's/[[:space:]]*$//')
- album=$(echo "$group2" \
- | awk -F " — " '{print $2}')
- date=$(echo "$group2" \
- | awk -F " — " '{print $1}' \
+ album=$(echo "$TRACK" \
+ | awk -F "\t" '{print $3}')
+ date=$(echo "$TRACK" \
+ | awk -F "\t" '{print $2}' \
| awk '{print substr($0, 2, length($0) - 2)}')
echo -e "artist: ${artist}\ndate: ${date}\nalbum: ${album}"
@@ -1153,7 +1146,7 @@ TRACK_TEMP=$((echo -e "0 Return to Browse Menu\n---"; cat $HOME/.config/clerk/t
elif [[ "$TRACK" == "${add}: Add | ${insert}: Insert | ${replace}: Replace | ${rate}: Rate" ]]; then
AddTrackTags
else
- filename=$(echo "$TRACK" | awk -F "\t" '{print $3}')
+ filename=$(echo "$TRACK" | awk -F "\t" '{print $5}')
echo -e "artist: ${artist}\nalbum: ${album}\ntitle: ${title}\ntrack: ${track}\ndate: ${date}\ngroup1: ${group1}\ngroup2: ${group2}"
if [[ $val -eq 11 ]]; then