aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/ipass
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/ipass')
-rwxr-xr-x.local/bin/ipass48
1 files changed, 40 insertions, 8 deletions
diff --git a/.local/bin/ipass b/.local/bin/ipass
index b19137a..4f555e4 100755
--- a/.local/bin/ipass
+++ b/.local/bin/ipass
@@ -1,19 +1,51 @@
#! /usr/bin/env sh
-main()
-{
+main() {
cd -- "$HOME/.password-store" || exit 1
- file="$(find ./* -type f | sed 's-^\./--' | sed 's-\.gpg$--' | dmenu)"
- dmenu_exit=$?
+ if [ -n "$WAYLAND_DISPLAY" ]
+ then
+ file="$(pass_list | fuzzel -d)"
+ pass_get "$file" | wl-copy
+
+ notify "Copied $file to clipboard!"
+ exit 0
+ fi
- if [ "$dmenu_exit" -ne 0 ]
+ if [ -n "$DISPLAY" ]
then
- exit 2
+ 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
- pass show "$file" | head -n 1 | perl -pe 'chomp' | xdotool type --file -
- notify-send -i "dialog-password" "ipass" "$file"
+ 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 "$@"