summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2017-07-16 17:36:21 +0200
committerRasmus Steinke <rasi@xssn.at>2017-07-16 17:36:21 +0200
commit58d7c8cdf645478522fa6f74ea54469a62dc9237 (patch)
tree924db63634bdfe62f583c94590886c65304b2c02
parentf0483ca2c4768b5fcccff50480bac722b7a8e7c6 (diff)
downloadclerk-perl_column.tar.gz
clerk-perl_column.tar.bz2
use pure awk for cache creationperl_column
-rwxr-xr-xclerk11
-rwxr-xr-xclerk_column.pl28
-rwxr-xr-xclerk_fzf/clerk_fzf19
3 files changed, 15 insertions, 43 deletions
diff --git a/clerk b/clerk
index f427f50..492cd26 100755
--- a/clerk
+++ b/clerk
@@ -177,19 +177,18 @@ updateCache () {
| perl -ne 'print unless $seen{$_}++' \
| sed 's:/[^/]*$::' | awk -F ' ○ ' '!seen[$1 $2 $3 $4]++' \
| uniq \
- | gawk -F ' ○ ' '{ printf "%."'${artist_width}'"s\t%."'${date_width}'"s\t%."'${album_width}'"s\t%.300s\n", $1, $2, $3, $4 }' \
- | clerk_column.pl > $HOME/.config/clerk/latest.cache
+ | gawk -F ' ○ ' '{ printf "%-"'${artist_width}'"."'${artist_width}'"s\t%-"'${date_width}'"."'${date_width}'"s\t%-"'${album_width}'"."'${album_width}'"s\t%.300s\n", $1, $2, $3, $4 }' \
+ > $HOME/.config/clerk/latest.cache
mpc --format '[%albumartist%|%artist%]\t(%date%)\t%album% [(CD %disc%)]\t%file%' \
search filename '' \
| sed 's:/[^/]*$::' \
| awk -F '\t' '!seen[$1 $2 $3 $4]++' \
| sort \
- | gawk -F '\t' '{ printf "%."'${artist_width}'"s\t%."'${date_width}'"s\t%."'${album_width}'"s\t%.300s\n", $1, $2, $3, $4 }' \
- | clerk_column.pl > $HOME/.config/clerk/albums.cache
+ | gawk -F '\t' '{ printf "%-"'${artist_width}'"."'${artist_width}'"s\t%-"'${date_width}'"."'${date_width}'"s\t%-"'${album_width}'"."'${album_width}'"s\t%.300s\n", $1, $2, $3, $4 }' \
+ > $HOME/.config/clerk/albums.cache
mpc --format '%track%\t%title%\t%artist%\t(%date%)\t%album%\t%file%' \
search filename '' \
- | gawk -F '\t' '{ 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 }' \
- | clerk_column.pl \
+ | gawk -F '\t' '{ printf "%-"'${track_width}'"."'${track_width}'"s\t%-"'${title_width}'"."'${title_width}'"s\t%-"'${artist_width}'"."'${artist_width}'"s\t%-"'${date_width}'"."'${date_width}'"s\t%-"'${album_width}'"."'${album_width}'"s\t%.500s\n", $1, $2, $3, $4, $5, $6 }' \
> $HOME/.config/clerk/tracks.cache
notify-send "clerk" "finished updating cache files"
date=$(mpc stats | grep 'DB Updated: ')
diff --git a/clerk_column.pl b/clerk_column.pl
deleted file mode 100755
index 34f6531..0000000
--- a/clerk_column.pl
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/perl
-
-# written by Florian Pritz <bluewind@xinu.at>
-
-use Data::Dumper;
-my %width = ();
-my @lines = ();
-while (my $line = <>) {
- chomp $line;
- push @lines, $line;
- my @parts = split(/\t/, $line);
- my $counter = 0;
- for (; $counter < @parts; $counter++) {
- my $partlen = length($parts[$counter]);
- $width{$counter} = $partlen if !defined($width{$counter}) or $partlen > $width{$counter}
- }
-}
-
-for my $line (@lines) {
- my @parts = split(/\t/, $line);
- my $counter = 0;
- for (; $counter < @parts - 1; $counter++) {
- $parts[$counter] =~ s/\s+$//;
- my $partlen = $width{$counter};
- printf "%-*s\t", $partlen, $parts[$counter];
- }
- printf "%s\n", $parts[-1];
-}
diff --git a/clerk_fzf/clerk_fzf b/clerk_fzf/clerk_fzf
index a51fd88..e10273c 100755
--- a/clerk_fzf/clerk_fzf
+++ b/clerk_fzf/clerk_fzf
@@ -174,8 +174,8 @@ fix_date_format() {
'
}
-
updateCache () {
+ notify-send "clerk" "updating cache files"
cd $HOME/.config/clerk
rm -f *.cache
@@ -185,22 +185,22 @@ updateCache () {
| sort -nr \
| gawk '{for (i=2; i<NF; i++) printf $i " "; print $NF }' \
| perl -ne 'print unless $seen{$_}++' \
- | sed 's:/[^/]*$::' | gawk -F ' ○ ' '!seen[$1 $2 $3 $4]++' \
+ | sed 's:/[^/]*$::' | awk -F ' ○ ' '!seen[$1 $2 $3 $4]++' \
| uniq \
- | gawk -F ' ○ ' '{ printf "%."'${artist_width}'"s\t%."'${date_width}'"s\t%."'${album_width}'"s\t%.300s\n", $1, $2, $3, $4 }' \
- | clerk_column.pl > $HOME/.config/clerk/latest.cache
+ | gawk -F ' ○ ' '{ printf "%-"'${artist_width}'"."'${artist_width}'"s\t%-"'${date_width}'"."'${date_width}'"s\t%-"'${album_width}'"."'${album_width}'"s\t%.300s\n", $1, $2, $3, $4 }' \
+ > $HOME/.config/clerk/latest.cache
mpc --format '[%albumartist%|%artist%]\t(%date%)\t%album% [(CD %disc%)]\t%file%' \
search filename '' \
| sed 's:/[^/]*$::' \
- | gawk -F '\t' '!seen[$1 $2 $3 $4]++' \
+ | awk -F '\t' '!seen[$1 $2 $3 $4]++' \
| sort \
- | gawk -F '\t' '{ printf "%."'${artist_width}'"s\t%."'${date_width}'"s\t%."'${album_width}'"s\t%.300s\n", $1, $2, $3, $4 }' \
- | clerk_column.pl > $HOME/.config/clerk/albums.cache
+ | gawk -F '\t' '{ printf "%-"'${artist_width}'"."'${artist_width}'"s\t%-"'${date_width}'"."'${date_width}'"s\t%-"'${album_width}'"."'${album_width}'"s\t%.300s\n", $1, $2, $3, $4 }' \
+ > $HOME/.config/clerk/albums.cache
mpc --format '%track%\t%title%\t%artist%\t(%date%)\t%album%\t%file%' \
search filename '' \
- | gawk -F '\t' '{ 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 }' \
- | clerk_column.pl \
+ | gawk -F '\t' '{ printf "%-"'${track_width}'"."'${track_width}'"s\t%-"'${title_width}'"."'${title_width}'"s\t%-"'${artist_width}'"."'${artist_width}'"s\t%-"'${date_width}'"."'${date_width}'"s\t%-"'${album_width}'"."'${album_width}'"s\t%.500s\n", $1, $2, $3, $4, $5, $6 }' \
> $HOME/.config/clerk/tracks.cache
+ notify-send "clerk" "finished updating cache files"
date=$(mpc stats | grep 'DB Updated: ')
file="$HOME/.config/clerk/.lastupdate"
echo "${date}" > "${file}"
@@ -209,6 +209,7 @@ updateCache () {
exit
fi
}
+
if [[ $1 == "--update" ]]; then
:
else