From 4d114c959afbac8bece359a9204673a3f6406fc1 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Sun, 4 May 2025 18:00:06 -0400 Subject: [PATCH] AutoYADM commit: 2025-05-04 18:00:06 --- .config/niri/scripts/rbw-fish.fish | 3 ++ .config/niri/scripts/rbw-menu.sh | 44 ++++++++++++++++++++++ .config/niri/scripts/rofi-rbw-wrapper.fish | 26 +++++++------ 3 files changed, 62 insertions(+), 11 deletions(-) create mode 100755 .config/niri/scripts/rbw-fish.fish create mode 100644 .config/niri/scripts/rbw-menu.sh diff --git a/.config/niri/scripts/rbw-fish.fish b/.config/niri/scripts/rbw-fish.fish new file mode 100755 index 00000000..4402089f --- /dev/null +++ b/.config/niri/scripts/rbw-fish.fish @@ -0,0 +1,3 @@ +#!/usr/bin/env fish + +echo rbw-fish \ No newline at end of file diff --git a/.config/niri/scripts/rbw-menu.sh b/.config/niri/scripts/rbw-menu.sh new file mode 100644 index 00000000..7b7ad956 --- /dev/null +++ b/.config/niri/scripts/rbw-menu.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env sh +set -eu +IFS=' + +' +# Creator: Robert Buchberger +# @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 diff --git a/.config/niri/scripts/rofi-rbw-wrapper.fish b/.config/niri/scripts/rofi-rbw-wrapper.fish index 8f5094c0..dfa15f91 100755 --- a/.config/niri/scripts/rofi-rbw-wrapper.fish +++ b/.config/niri/scripts/rofi-rbw-wrapper.fish @@ -1,17 +1,21 @@ #!/usr/bin/env fish +set -l opts --selector fuzzel --clipboarder wl-copy --typer wtype --use-notify-send + set -l cmd (echo type\ncopy\nprint\n | fuzzel --prompt="Mode: " --dmenu) -set -l opts --selector fuzzel --clear-after 60 --clipboarder wl-copy --typer wtype --use-notify-send +set -l target (echo username\npassword\nautotype | fuzzel --prompt="Targets: " --dmenu) -rofi-rbw $opts --action $cmd +if not test "$target" = both + set --append opts --target $target +end -# if test "$cmd" = type -# rofi-rbw $opts --action type -# else if test "$cmd" = copy -# rofi-rbw $opts --action copy -# else if test "$cmd" = print -# rofi-rbw $opts --action print -# else -# return 1 -# end +if test "$cmd" = type + rofi-rbw $opts --action type +else if test "$cmd" = copy + rofi-rbw $opts --action copy +else if test "$cmd" = print + notify-send --wait (rofi-rbw $opts --action print | string collect -N) +else + return 1 +end