mattydebie / bitwarden-rofi

Wrapper for Bitwarden https://github.com/bitwarden/cli and Rofi
GNU General Public License v3.0
346 stars 56 forks source link

Increasing Loadspeed #51

Closed moukle closed 1 year ago

moukle commented 4 years ago

For bwmenu to open it takes 1.09s on my machine.

$ time bwmenu # holding esc
bwmenu  1.09s user 0.10s system 156% cpu 0.764 total

This can get quite annoying sometimes, when searching immediately for an entry but passing the text in the application input-field and not Rofi's.

I didn't have this issue with rofi-pass. Maybe the entry(-names) could be cached?

fabian-thomas commented 3 years ago

Yeah, some sort of caching would definitely speed things up. But there is another problem I noticed: When you run bw unlock in your terminal you have a delay of ~0.6 seconds until you can enter your master password. This also affects this rofi client. After you typed in your master pw and hit enter we can measure a delay of ~1.6 seconds (all on my machine; these numbers can differ) until the list of entries pops up. This is the pre delay of bw unlock (~0.6 seconds) plus the delay of getting the entries (~1 second) from your vault.

One option to remove the delay of bw unlock is to start that before you even enter your master pw and than pass your entered value to std input of the bw cli. This just navigates around the problems of bw-cli. Here is a hacky implementation for this kind of workaround: (Note that this is just a proof of concept. Both the usage of screen and the while sleep loop is suboptimal)

ask_password() {
  screen_name="bitwarden-rofi-unlock"
  screen -L -S $screen_name -d -m bw unlock --raw
  mpw=$(printf '' | rofi -dmenu -p "Master Password" -password -lines 0) || exit $?
  screen -S $screen_name -p 0 -X stuff "$mpw^M"

  while screen -list | grep -q $screen_name
  do
      sleep 0.01
  done

  tail -n 1 screenlog.0
}

Is there another fix for both of these problems? Actually yeah. I found a non-official bw-cli client today that has a rofi wrapper too. This combination works better (at least for me). https://github.com/doy/rbw https://github.com/fdw/rofi-rbw

wwalker commented 2 years ago

Just a comment, nothing solid here... just some observations.

I looked into this and I'm seeing that either bw or rbw is CPU bound. I also wrote my own bw wrappers before I found bitwarden-rofi. In timing tests there are things like this:

$ time bw status
{"serverUrl":"https://platinum.solid-constructs.com","lastSync":null,"userEmail":null,"userId":null,"status":"unauthenticated"}

real    0m1.176s
user    0m1.157s
sys     0m0.083s

$ time rbw unlocked
rbw unlocked: agent is locked

real    0m0.015s
user    0m0.003s
sys     0m0.010s

As long as you are using bw, things will be slow.

However my tests of rofi-rbw vs bitwarden-rofi showed they were about the same speed...

rofi-rbw should be at least 1 second faster ...