Skip to content

Commit

Permalink
Merge pull request #97 from blueyed/mainmenu-performance
Browse files Browse the repository at this point in the history
Improve performance in mainMenu: short-circuit actions without entries
  • Loading branch information
carnager authored Oct 26, 2017
2 parents 53a76af + f6c21dd commit 2977f83
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions rofi-pass
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;;
Expand All @@ -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
Expand Down

0 comments on commit 2977f83

Please sign in to comment.