summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2017-08-04 06:59:19 +0200
committerRasmus Steinke <rasi@xssn.at>2017-08-04 06:59:19 +0200
commitb51409ecde21fc408fdb7e4e69318d8d911c0d95 (patch)
treee28880eef0ef42c76bb3fa5f6416673395a8518c
parenta12c133d5aebeba9a34421dabf33737e8a6c50ee (diff)
downloadperl-app-clerk-b51409ecde21fc408fdb7e4e69318d8d911c0d95.tar.gz
perl-app-clerk-b51409ecde21fc408fdb7e4e69318d8d911c0d95.tar.xz
make chunksize a config option
-rw-r--r--clerk.conf10
-rwxr-xr-xclerk.pl5
2 files changed, 13 insertions, 2 deletions
diff --git a/clerk.conf b/clerk.conf
index cf188a3..51b3765 100644
--- a/clerk.conf
+++ b/clerk.conf
@@ -1,9 +1,19 @@
[General]
+# MPD_HOST will override this
mpd_host=tauron
+
+# define where clerk should save its cache files
database=/home/carnager/.config/clerk/db_msgpack
+
+# backend to use, possible options: fzf and rofi
backend=fzf
+# number of songs clerk will get at once for creating its cache files
+# if mpd drops the connection while updating, reduce this.
+chunksize=30000
+
[Columns]
+# width of columns
albumartist_l=50
album_l=118
artist_l=66
diff --git a/clerk.pl b/clerk.pl
index f371a57..bbd661c 100755
--- a/clerk.pl
+++ b/clerk.pl
@@ -29,6 +29,7 @@ my $general_cfg = $cfg->param(-block=>"General");
my $mpd_host = $general_cfg->{mpd_host};
my $db_file = $general_cfg->{database};
my $backend = $general_cfg->{backend};
+my $chunksize = $general_cfg->{chunksize};
my $columns_cfg = $cfg->param(-block=>"Columns");
my $albumartist_l = $columns_cfg->{albumartist_l};
@@ -65,11 +66,11 @@ sub create_db {
if (!-f "$db_file" || stat("$db_file")->mtime < $last_update) {
print STDERR "::: No cache found or cache file outdated\n";
- my $times = int($songcount / 1000 + 1);
+ my $times = int($songcount / $chunksize + 1);
print STDERR "::: Requesting $times chunks from MPD\n";
my @db;
# since mpd will silently fail, if response is larger than command buffer, let's split the search.
- my $chunk_size = 1000;
+ my $chunk_size = $chunksize;
for (my $i=0;$i<=$songcount;$i+=$chunk_size) {
my $endnumber = $i+$chunk_size;
my @temp_db = $mpd->search('filename', '', 'window', "$i:$endnumber");