diff options
author | Rasmus Steinke <rasi@xssn.at> | 2017-08-05 21:29:04 +0200 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2017-08-05 21:29:04 +0200 |
commit | 6582e82885d50499dd63ce735d1927da038560d7 (patch) | |
tree | aa653bcb082547b862138cf8c88c70fc9c0a4f01 | |
parent | 2b9ea774c6eb1e3ffdbfc99f555dc45dd1023c54 (diff) | |
download | perl-app-clerk-6582e82885d50499dd63ce735d1927da038560d7.tar.gz perl-app-clerk-6582e82885d50499dd63ce735d1927da038560d7.tar.xz |
automatically run rofi on cli arguments
-rwxr-xr-x | clerk | 26 | ||||
-rw-r--r-- | install.sh | 12 |
2 files changed, 20 insertions, 18 deletions
@@ -56,6 +56,20 @@ my $mpd = Net::MPD->connect($ENV{MPD_HOST} // $mpd_host // 'localhost'); sub main { create_db(); + my %options=(); + getopts("talp", \%options); + + $backend = 'rofi' if scalar %options; + if (defined $options{t}) { + list_db_entries_for("Tracks"); + } elsif (defined $options{a}) { + list_db_entries_for("Albums"); + } elsif (defined $options{p}) { + list_playlists(); + } elsif (defined $options{l}) { + my $backend="rofi"; + list_db_entries_for("Latest"); + } if ($backend eq "fzf") { system('tmux', 'has-session', '-t', 'music'); if ($? != -0) { @@ -68,18 +82,6 @@ sub main { system('tmux', 'attach', '-t', 'music'); } # elsif ($backend eq "rofi") { - my %options=(); - getopts("talp", \%options); - - if (defined $options{t}) { - list_db_entries_for("Tracks"); - } elsif (defined $options{a}) { - list_db_entries_for("Albums"); - } elsif (defined $options{p}) { - list_playlists(); - } elsif (defined $options{l}) { - list_db_entries_for("Latest"); - } } @@ -16,7 +16,7 @@ read -e -p "Proceed? (Y/n) > " go_on go_on=${go_on:-y} case $go_on in - n) exit; + [Nn]) exit; ;; esac @@ -25,12 +25,12 @@ cpan_arch=${cpan_arch:-y} case $cpan_arch in - y) if [[ -z $(pacman -Qsq perl-cpanplus-dist-arch) ]] + [Yy]) if [[ -z $(pacman -Qsq perl-cpanplus-dist-arch) ]] then read -e -p "perl-cpanplus-dist-arch package not found. Install? (Y/n) > " cpanp_dist_install cpanp_dist_install=${cpanp_dist_install:-y} case $cpanp_dist_install in - y) yes | sudo pacman -S perl-cpanplus-dist-arch + [Yy]) yes | sudo pacman -S perl-cpanplus-dist-arch ;; esac fi @@ -41,7 +41,7 @@ read -e -p "Install dependencies for clerk? (Y/n) > " deps_choice deps_choice=${deps_choice:-y} case "${deps_choice}" in - y) + [Yy]) for dep in "${dependencies[@]}" do cpanp i "${dep}" @@ -53,7 +53,7 @@ esac read -e -p "Set installation directory. (Default: $HOME/bin) > " foo foo=${foo:-$HOME/bin} case $foo in - y) export path="$HOME/bin"; + [Yy]) export path="$HOME/bin"; ;; *) export path="$foo"; ;; @@ -63,7 +63,7 @@ read -e -p "Install clerk to $path? (Y/n) > " install install=${install:-y} case $install in - y) cp clerk $path; + [Yy]) cp clerk $path; if [[ ! -d "${HOME}/.config/clerk" ]] then mkdir "${HOME}/.config/clerk" |