diff options
author | Daniel Hahler <git@thequod.de> | 2017-10-25 23:03:11 +0200 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2017-10-25 23:03:11 +0200 |
commit | f6c21ddacbd75fd804a17444500b2724d51b9964 (patch) | |
tree | ceab099b02ae170bb7db86084aea459ebdc3763b | |
parent | efb3cd412f97293cacc13827848779731c100fa9 (diff) | |
download | rofi-pass-f6c21ddacbd75fd804a17444500b2724d51b9964.tar.gz |
Improve performance in mainMenu: short-circuit actions without entries
This makes e.g. displaying the help faster.
-rwxr-xr-x | rofi-pass | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -298,6 +298,16 @@ mainMenu () { if [[ $rofi_exit -eq 1 ]]; then exit fi + + # Actions based on exit code, which do not need the entry. + # The exit code for -kb-custom-X is X+9. + case "${rofi_exit}" in + 19) roots_index=$(( (roots_index-1+roots_length) % roots_length)); root=${roots[$roots_index]}; mainMenu;; + 20) roots_index=$(( (roots_index+1) % roots_length)); root=${roots[$roots_index]}; mainMenu;; + 25) helpMenu; return;; + 26) ${basecommand} --bmarks; return;; + esac + mapfile -t password_temp < <(PASSWORD_STORE_DIR="${root}" pass "$selected_password") password=${password_temp[0]} if [[ ${password} == "#FILE="* ]]; then @@ -340,6 +350,7 @@ mainMenu () { pass_content="$(for key in "${!stuff[@]}"; do printf '%s\n' "${key}: ${stuff[$key]}"; done)" # actions based on keypresses + # The exit code for -kb-custom-X is X+9. case "${rofi_exit}" in 0) typeMenu;; 10) sleep $wait; autopass;; @@ -350,13 +361,9 @@ mainMenu () { 15) copyPass;; 16) viewEntry;; 17) copyURL;; - 18) export default_do="menu"; typeMenu;; - 19) roots_index=$(( (roots_index-1+roots_length) % roots_length)); root=${roots[$roots_index]}; mainMenu;; - 20) roots_index=$(( (roots_index+1) % roots_length)); root=${roots[$roots_index]}; mainMenu;; + 18) default_do="menu" typeMenu;; 23) actionMenu;; 24) copyMenu;; - 25) unset selected_password; helpMenu;; - 26) ${basecommand} --bmarks;; 27) insertPass;; esac clearUp |