diff options
author | Rasmus Steinke <rasi@xssn.at> | 2017-08-03 17:57:42 +0200 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2017-08-03 17:57:42 +0200 |
commit | fc1afc43a00bc1bacd1ac324934ea900c1d3facd (patch) | |
tree | 1ea1e7a9b0ed00c6d8166bc81ed2aac72f443d4a | |
parent | 717d3d363105ef1f5f2b878d2ba75f7316975af6 (diff) | |
download | perl-app-clerk-fc1afc43a00bc1bacd1ac324934ea900c1d3facd.tar.gz perl-app-clerk-fc1afc43a00bc1bacd1ac324934ea900c1d3facd.tar.xz |
simplify variable creation
-rw-r--r-- | clerk.pl | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -40,7 +40,7 @@ my $mpd = Net::MPD->connect($ENV{MPD_HOST} // $mpd_host // 'localhost'); sub main { create_db(); - list_albums(); + list_tracks(); } @@ -91,7 +91,7 @@ sub backend_call { my ($in) = @_; my $input; my $out; - my %backends = ( fzf => [ qw(fzf --reverse --no-sort -m -e -i --with-nth=1,2,3 -d "\t" --tabstop=4 +s --ansi) ], rofi => ['rofi', '-width', '1300', '-dmenu', '-i', '-p', '> ']); + my %backends = ( fzf => [ 'fzf', '--reverse', '--no-sort', '-m', '-e', '-i', '--with-nth=1,2,3', '-d', '\t', '--tabstop=4', '+s', '--ansi' ], rofi => ['rofi', '-width', '1300', '-dmenu', '-i', '-p', '> ']); my $handle = start $backends{$backend} // die('backend not found'), \$input, \$out; $input = join "", (@{$in}); finish $handle or die "No selection"; @@ -165,18 +165,14 @@ sub list_tracks { my @output; my $in; for my $entry (@{$rdb}) { - $in = sprintf "%-${track_l}.${track_l}s\t%-${title_l}.${title_l}s\t%-${artist_l}.${artist_l}s\t%-${album_l}.${album_l}s\t%-s\n", $entry->{Track},$entry->{Title}, $entry->{Artist}, $entry->{Album}, $entry->{uri}; + $in = sprintf "%-${track_l}.${track_l}s\t%-${title_l}.${title_l}s\t%-${artist_l}.${artist_l}s\t%-${album_l}.${album_l}s\t%-s\n", $entry->@{qw/Track Title Artist Album uri/}; push @output, $in; } my $out = backend_call(\@output); my $uri = (split /[\t\n]/, $out)[-1]; my $songinfo = $mpd->search('filename' => $uri); - my $artist=$songinfo->{Artist}; - my $album=$songinfo->{Album}; - my $title=$songinfo->{Title}; - my $track=$songinfo->{Track}; - my $date=$songinfo->{Date}; + my ($artist, $album, $title, $track, $date) = $songinfo->@{qw/Artist Album Title Track Date/}; print "::: Selected \"$title\" from artist \"$artist\" of album \"$album\"\n"; my @action_items = ("Add\n", "Insert\n", "Replace\n"); |