AutoYADM commit: 2025-05-04 18:00:06
This commit is contained in:
parent
62b35dcdbf
commit
4d114c959a
3 changed files with 62 additions and 11 deletions
44
.config/niri/scripts/rbw-menu.sh
Normal file
44
.config/niri/scripts/rbw-menu.sh
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env sh
|
||||
set -eu
|
||||
IFS='
|
||||
|
||||
'
|
||||
# Creator: Robert Buchberger <robert@buchberger.cc>
|
||||
# @robert@spacey.space
|
||||
#
|
||||
# Select an item from bitwarden with wofi, return value for passed query
|
||||
# Dependencies: rbw installed and configured
|
||||
#
|
||||
# Usage: rbw-menu [query]
|
||||
# query: "code" or anything on the login object; username, password, totp, etc
|
||||
# - code will return a TOTP code
|
||||
# - anything else will return the value of the query
|
||||
# default: username
|
||||
|
||||
# Check if rbw is locked, redirect stderr and stdout to /dev/null. Unlock if
|
||||
# necessary.
|
||||
rbw unlocked >/dev/null 2>&1 || rbw unlock
|
||||
|
||||
query=${1:-username}
|
||||
|
||||
chosen_item=$(
|
||||
# If RBW_MENU_COMMAND is unset, use wofi
|
||||
if [ "${RBW_MENU_COMMAND:-}" = "" ]; then
|
||||
rbw list | wofi --dmenu --matching fuzzy --insensitive --prompt "$query"
|
||||
else
|
||||
eval "rbw list | $RBW_MENU_COMMAND"
|
||||
fi
|
||||
)
|
||||
|
||||
# Exit if user didn't select anything
|
||||
[ "$chosen_item" = "" ] && exit 1
|
||||
|
||||
case "$query" in
|
||||
code)
|
||||
rbw code "$chosen_item"
|
||||
;;
|
||||
*)
|
||||
# Select chosen item from vault, return login.query
|
||||
rbw get "$chosen_item" --raw | jq --join-output ".data.$query"
|
||||
;;
|
||||
esac
|
Loading…
Add table
Add a link
Reference in a new issue