summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2017-10-01 01:19:21 +0200
committerRasmus Steinke <rasi@xssn.at>2017-10-01 01:19:21 +0200
commit0b1842f256dc17cbbc2cc15db93047e759dd81ba (patch)
treef7ccce563010cd342c3b43e26b2ebb3b3d68748a
parent349a51ea51a95095d4dabc63b2a4ccee05d62894 (diff)
downloadperl-app-clerk-0b1842f256dc17cbbc2cc15db93047e759dd81ba.tar.gz
perl-app-clerk-0b1842f256dc17cbbc2cc15db93047e759dd81ba.tar.xz
allow setting of track mode for random menu
-rwxr-xr-xclerk27
1 files changed, 21 insertions, 6 deletions
diff --git a/clerk b/clerk
index f4fdef5..6202d33 100755
--- a/clerk
+++ b/clerk
@@ -446,13 +446,18 @@ sub ask_to_pick_playlists {
}
sub ask_to_pick_random {
- return backend_call(["Tracks\n", "Albums\n", "Settings\n"]);
+ return backend_call(["Tracks\n", "Albums\n", "---\n", "Mode: $rvar{randomartist}\n", "Number of Songs: $rvar{songs}\n"]);
}
-sub ask_to_pick_settings {
+sub ask_to_pick_song_number {
return backend_call([map { $_ . "\n" } qw/5 10 15 20 25 30/]);
}
+sub ask_to_pick_track_settings {
+ return backend_call(["artist\n", "albumartist\n"]);
+}
+
+
sub ask_to_pick_ratings {
return backend_call([map { $_ . "\n" } (qw/1 2 3 4 5 6 7 8 9 10 ---/), "Delete Rating"]);
}
@@ -511,13 +516,14 @@ sub action_random {
mpd_reachable();
{
local $_ = $out;
- if (/^Track/) { random_tracks() }
- elsif (/^Album/) { random_album() }
- elsif (/^Settings/) { action_settings(ask_to_pick_settings()) }
+ if (/^Track/) { random_tracks() }
+ elsif (/^Album/) { random_album() }
+ elsif (/^Mode: $rvar{randomartist}/) { action_track_mode(ask_to_pick_track_settings()) }
+ elsif (/^Number of Songs: $rvar{songs}/) { action_song_number(ask_to_pick_song_number()) }
}
}
-sub action_settings {
+sub action_song_number {
my ($out) = @_;
$rvar{songs} = max map { split /[\t\n]/ } (split /\n/, $out);
@@ -526,6 +532,15 @@ sub action_settings {
$cfg->save();
}
+sub action_track_mode {
+ my ($out) = $_[0];
+ chomp $out;
+ $rvar{randomartist} = $out;
+
+ $cfg->param("General.randomartist", $rvar{randomartist});
+ $cfg->save();
+}
+
sub util_parse_selection {
my ($sel) = @_;
map { (split /[\t\n]/, $_)[-1] } (split /\n/, decode('UTF-8', $sel));