fdw / rofi-rbw

Rofi frontend for Bitwarden
https://github.com/fdw/rofi-rbw/
MIT License
192 stars 25 forks source link

rofi-rbw hangs when action is copy and the output is assigned to a bash variable #92

Closed jonboh closed 6 months ago

jonboh commented 6 months ago

I wanted to send the output from rofi-rbw to a window to display a password and keep the copy actions, however rofi-rbw hangs in this case.

PASSWORD=$(rofi-rbw)
echo "$PASSWORD" # this won't execute if you exit rofi with Alt+c

If instead you exit with Enter, the output is properly displayed. I would have expected to just display an empty string.

fdw commented 6 months ago

A couple of questions:

jonboh commented 6 months ago

Ah, forgot to report the version:

$ rofi-rbw --version
rofi-rbw 1.3.0

In the script I actually use, I do define --action and --clear-after:

PASSWORD=$(
      rofi-rbw \
        --clear-after 15 \
        --action print \
        --keybindings "Alt+p:type:password,Alt+P:print:password,Alt+c:copy:password,Alt+u:copy:username,Alt+s:sync"
)

However, this isn't necessary to reproduce the issue, with all the defaults the problem still appears when rofi-rbw is closed with a copy action (instead of Enter or Ctrl+C)

Edit: To clarify, the clipboard and clear-after functionality work correctly. The only problem is that rofi-rbw won't exit and let scripts continue running if you use the clipboard actions.

fdw commented 6 months ago

I can reproduce this, but I can also see that the rofi-rbw process stops. The problem seems to be that the clipboarder keeps running in the background, which required for it to work (at least on X, I haven't checked Wayland). So, there is nothing I can change and things are actually working as designed 😉

If you want to use rofi-rbw in a script, I recommend to use the print action and do whatever else you need in your script.