From 6582e82885d50499dd63ce735d1927da038560d7 Mon Sep 17 00:00:00 2001 From: Rasmus Steinke Date: Sat, 5 Aug 2017 21:29:04 +0200 Subject: automatically run rofi on cli arguments --- clerk | 26 ++++++++++++++------------ install.sh | 12 ++++++------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/clerk b/clerk index 9d4888a..b9b4a27 100755 --- a/clerk +++ b/clerk @@ -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"); - } } diff --git a/install.sh b/install.sh index c7fa3aa..1358431 100644 --- a/install.sh +++ b/install.sh @@ -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" -- cgit v1.2.3-24-g4f1b