#! /usr/bin/env sh main() { cd -- "$HOME/.password-store" || exit 1 if [ -n "$WAYLAND_DISPLAY" ] then file="$(pass_list | fuzzel -d)" pass_get "$file" | wl-copy notify "Copied $file to clipboard!" exit 0 fi if [ -n "$DISPLAY" ] then file="$(pass_list | dmenu)" pass_get "$file" | xdotool type --file - dmenu_exit=$? if [ "$dmenu_exit" -ne 0 ] then notify "Error typing $file" exit 2 fi notify "Typing $file" exit 0 fi notify "No graphical environment detected" } pass_list() { find ./* -type f \ | sed 's-^\./--' \ | sed 's-\.gpg$--' } pass_get() { pass show "$1" \ | head -n 1 \ | perl -pe 'chomp' } notify() { notify-send -i "dialog-password" "ipass" "$*" } main "$@"