From 5083c181fd034a3d9332869e6e8ead500ad544b8 Mon Sep 17 00:00:00 2001 From: Rasmus Steinke Date: Fri, 5 Aug 2016 04:16:30 +0200 Subject: [PATCH] Respect default_do config setting and allow "menu" value. Fixes #52 --- config.example | 2 +- rofi-pass | 40 ++++++++++++++++++++++++---------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/config.example b/config.example index ba17a51..49ad2da 100644 --- a/config.example +++ b/config.example @@ -26,7 +26,7 @@ BROWSER='chromium' ## Misc settings -default_do='autopass' # copyPass, typeUser, typePass, copyUser, copyUrl, viewEntry, typeMenu, actionMenu, copyMenu, openUrl +default_do='menu' # menu, copyPass, typeUser, typePass, copyUser, copyUrl, viewEntry, typeMenu, actionMenu, copyMenu, openUrl auto_enter='false' notify='false' passlength='20' diff --git a/rofi-pass b/rofi-pass index 1ff9999..6c4402c 100755 --- a/rofi-pass +++ b/rofi-pass @@ -13,7 +13,7 @@ URL_field='url' USERNAME_field='user' AUTOTYPE_field='autotype' delay=2 -default_do='autopass' # copyPass, typeUser, typePass, copyUser, copyUrl, viewEntry, typeMenu, actionMenu, copyMenu, openUrl +default_do='menu' # menu, copyPass, typeUser, typePass, copyUser, copyUrl, viewEntry, typeMenu, actionMenu, copyMenu, openUrl auto_enter='false' notify='false' passlength='20' @@ -324,22 +324,30 @@ else unset helptext; mainMenu; fi } typeMenu () { - checkIfPass - typefield=$(printf '%s\n' "${!stuff[@]}" | sort | _rofi -kb-accept-entry '!Return' -dmenu -p "Choose Field to type > ") - val=$? - if [[ $val -eq 1 ]]; then - exit + clear + echo "${default_do}" + if [[ -n $default_do ]]; then + if [[ $default_do == "menu" ]]; then + checkIfPass + typefield=$(printf '%s\n' "${!stuff[@]}" | sort | _rofi -kb-accept-entry '!Return' -dmenu -p "Choose Field to type > ") + val=$? + if [[ $val -eq 1 ]]; then + exit + fi + if [[ $typefield == "" ]]; then + exit; + elif [[ $typefield == "password" ]]; then + typePass + elif [[ $typefield == "${AUTOTYPE_field}" ]]; then + autopass + else + typeField + fi + clearUp + else + $(${default_do}) + fi fi - if [[ $typefield == "" ]]; then - exit; - elif [[ $typefield == "password" ]]; then - typePass - elif [[ $typefield == "${AUTOTYPE_field}" ]]; then - autopass - else - typeField - fi - clearUp } copyMenu () {