summaryrefslogtreecommitdiffstats
path: root/clerk.pl
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2017-08-03 20:52:54 +0200
committerRasmus Steinke <rasi@xssn.at>2017-08-03 20:52:54 +0200
commit5987a9ea71608ac49a32ef5cbc7214bdf1ffc7df (patch)
treeb8ab7e388ba853c4c9de9a076b63160a94e7e83a /clerk.pl
parentd9dde458c07d3b2f32356692eea4fd353b2b6c79 (diff)
downloadperl-app-clerk-5987a9ea71608ac49a32ef5cbc7214bdf1ffc7df.tar.gz
perl-app-clerk-5987a9ea71608ac49a32ef5cbc7214bdf1ffc7df.tar.xz
outsource action menus and adding of tracks to sub function
Diffstat (limited to 'clerk.pl')
-rwxr-xr-xclerk.pl29
1 files changed, 9 insertions, 20 deletions
diff --git a/clerk.pl b/clerk.pl
index b77dd9c..355de87 100755
--- a/clerk.pl
+++ b/clerk.pl
@@ -126,8 +126,16 @@ sub unpack_msgpack {
}
sub do_action {
+ my @action_items = ("Add\n", "Replace\n");
+ my $action = backend_call(\@action_items);
+ if ($action eq "Replace\n") {
+ $mpd->clear();
+ }
+ if ($action eq "Replace\n") {
+ $mpd->play();
+ }
my $input;
- my ($in, $action) = @_;
+ my ($in) = @_;
foreach my $line (split /\n/, $in) {
print "${line}x\n";
my $uri = (split /[\t\n]/, $line)[-1];
@@ -154,17 +162,7 @@ sub list_albums {
push @output, $in;
}
my $out = backend_call(\@output, "1,2,3");
- print $out;
- # call rofi function to display possible actions
- my @action_items = ("Add\n", "Replace\n");
- my $action = backend_call(\@action_items);
- if ($action eq "Replace\n") {
- $mpd->clear();
- }
do_action($out);
- if ($action eq "Replace\n") {
- $mpd->play();
- }
list_albums($rdb);
}
@@ -178,16 +176,7 @@ sub list_tracks {
push @output, $in;
}
my $out = backend_call(\@output, "1,2,3,4");
-
- my @action_items = ("Add\n", "Replace\n");
- my $action = backend_call(\@action_items);
- if ($action eq "Replace\n") {
- $mpd->clear();
- }
do_action($out);
- if ($action eq "Replace\n") {
- $mpd->play();
- }
list_tracks($rdb)
}