diff --git a/i3/config b/i3/config index 3c7d2c3..e86cd75 100644 --- a/i3/config +++ b/i3/config @@ -42,6 +42,7 @@ bindsym $mod+Shift+q kill # start dmenu (a program launcher) # bindsym $mod+d exec dmenu_run bindsym $mod+d exec rofi -show run +bindsym $mod+p exec ~/etc/rofipass.sh --type # There also is the (new) i3-dmenu-desktop which only displays applications # shipping a .desktop file. It is a wrapper around dmenu, so you need that # installed. diff --git a/rofipass.sh b/rofipass.sh new file mode 100755 index 0000000..f7f8142 --- /dev/null +++ b/rofipass.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +shopt -s nullglob globstar + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +fi + +prefix=${PASSWORD_STORE_DIR-~/.password-store} +password_files=( "$prefix"/**/*.gpg ) +password_files=( "${password_files[@]#"$prefix"/}" ) +password_files=( "${password_files[@]%.gpg}" ) + +password=$(printf '%s\n' "${password_files[@]}" | rofi -dmenu -p pass "$@") + +[[ -n $password ]] || exit + +if [[ $typeit -eq 0 ]]; then + pass show -c "$password" 2>/dev/null +else + xdotool - <<<"type --clearmodifiers -- $(pass show "$password" | head -n 1)" +fi