mattydebie/bitwarden-rofi

Custom item formatting and global search

Opened this issue · 2 comments

I've been using the great tool for a day now and I feel like I'm not seeing all of the information that I want to see or that it's not searching for the information I want it to search for. The Bitwarden's apps all search everywhere and then show this information in an overview similar to this:

---------
|favicon|  Entry name
|       |  Username
---------

The favicon gives away what website it's from, so without a GUI we can replace that with the domain (e.g. accounts.google.com). The entry name and username is something we can easily show. If this information is all shown at once, I assume we can search for it with rofi. Could this behaviour be added so there is 1 search bar that will get you everthing you need?

If we could fire up bwmenu with --item-format that would allow you to input a string that is then formatted and allows for a few parameters:

  • %name: Name of the password entry.
  • %username: Username on the service.
  • %website: Hostname of the website (github.com shortened from https://github.com/login, same as the Bitwarden extension shows).
  • %type: login, card, identity, or secure note.
  • %folder: the folder it is in.

This would allow for everyone to search for what he needs and not even show what they don't want because it is configurable. Perhaps if it is possible, we could have a separate search list that contains everything and then only show some part of that information. E.g.: for the entry for account.google.com with name@example.com and entry name Private, we could search for "Private", "google", or "name@example.com" (or combine them) and all see the entry we're looking for, but then configure it to only show "name@example.com (account.google.com)".

Mange commented

I suggest you try to implement some basic proof-of-concept of this feature; it'd be nice to have a working prototype to look at.


rofi has a -markup-rows option that allows some basic Pango formatting of strings (enabling colors, bold, italics, etc.), which could also be helpful showing more information.

Were you thinking of something like this? imagining the string in jq's output is parametrized.

show_items() {
  if item=$(
    echo "$ITEMS" \
    | jq -r '.[] | select(has("login")) | if .login.uris[0] then "\(.name) :: \(.login.username) :: \(.login.uris[].uri)"  else "\(.name) :: \(.login.username)" end' \
    | rofi_menu
  ); then
  item=$(echo "$ITEMS" | jq -r ".[] | select(.name == \"$(echo $item | cut -d ' ' -f1)\")")
    copy_password "$(echo $item | cut -d ' ' -f1)"
  else
    on_rofi_exit $? "$(echo $item | cut -d ' ' -f1)"
  fi
}

Which feeds rofi with items following this format:
<name> :: <login.username>[ :: <login.uris[?].uri>]

The drawback feature? is each entry corresponds to a single uri (if any) from the login.uris array. And will behave the same way with any array it may encounter within an item, eg. collectionIds