summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2017-08-08 02:33:10 +0200
committerRasmus Steinke <rasi@xssn.at>2017-08-08 02:33:10 +0200
commit3cff08f08aca0a99b7cac858e45fcb888260d82d (patch)
tree58db2f6fb3ff0614fae1505d8f0aebad49416a43
parentc94f86298577a96b5f48bad52a439b09c039c8de (diff)
downloadperl-app-clerk-3cff08f08aca0a99b7cac858e45fcb888260d82d.tar.gz
perl-app-clerk-3cff08f08aca0a99b7cac858e45fcb888260d82d.tar.xz
exit random menu on escape
-rwxr-xr-xclerk14
1 files changed, 8 insertions, 6 deletions
diff --git a/clerk b/clerk
index 1bdfb8a..110f19c 100755
--- a/clerk
+++ b/clerk
@@ -154,9 +154,11 @@ sub help {
}
sub backend_call {
- my ($in, $fields) = @_;
+ my ($in, $fields, $random) = @_;
my $input;
my $out;
+ $random //= "ignore";
+ print "$random\n";
$fields //= "1,2,3";
my %backends = (
fzf => [ qw(fzf
@@ -168,9 +170,9 @@ sub backend_call {
-d
\t
--tabstop=4
- --bind=esc:ignore
+s
--ansi),
+ "--bind=esc:$random",
"--with-nth=$fields"
],
rofi => [
@@ -217,7 +219,7 @@ sub unpack_msgpack {
sub random {
my @action_items = ("Album\n", "Tracks\n", "Settings\n");
- my $action = backend_call(\@action_items);
+ my $action = backend_call(\@action_items, "1,2,3", "cancel");
if ($action eq "Album\n") {
$mpd->clear();
my @album_artists = $mpd->list('albumartist');
@@ -282,7 +284,7 @@ sub list_playlists {
for (;;) {
my $out = backend_call($output);
- do_action($out, "playlist");
+ do_action($out, "playlist", "ignore");
}
}
@@ -356,12 +358,12 @@ sub list_db_entries_for {
my $output = $formater{$kind}->($rdb);
if ($backend eq "rofi") {
my $out = backend_call($output, $fields{$kind});
- do_action($out, "tracks");
+ do_action($out, "tracks", "ignore");
}
elsif ($backend eq "fzf") {
for (;;) {
my $out = backend_call($output, $fields{$kind});
- do_action($out, "tracks");
+ do_action($out, "tracks", "ignore");
}
}