aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRasmus Steinke <rasi@xssn.at>2017-10-26 02:36:38 +0200
committerGitHub <noreply@github.com>2017-10-26 02:36:38 +0200
commit2977f83b80b530e54affb4cc99a24ae4da886cda (patch)
tree30b018dd81729f006fa565939480723954d5ce82
parent53a76af4e8228222a1e5a932835574fb6f963237 (diff)
parentf6c21ddacbd75fd804a17444500b2724d51b9964 (diff)
downloadrofi-pass-2977f83b80b530e54affb4cc99a24ae4da886cda.tar.gz
Merge pull request #97 from blueyed/mainmenu-performance
Improve performance in mainMenu: short-circuit actions without entries
-rwxr-xr-xrofi-pass17
1 files changed, 12 insertions, 5 deletions
diff --git a/rofi-pass b/rofi-pass
index 9b28a1e..0171c3d 100755
--- a/rofi-pass
+++ b/rofi-pass
@@ -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