dots

Dotfiles for Linux
git clone https://git.ckiri.com/cmk/dots.git
Log | Files | Refs | README

passmenu.sh (690B)


      1 #!/usr/bin/bash
      2 #
      3 # Select a password from `pass` using wmenu (dmenu wayland) instead of dmenu.
      4 # Mocks the standart implementation of passmenu. 
      5 
      6 # Check if a wayland compositor is used, if not throw error
      7 if test -n $WAYLAND_DISPLAY; then
      8     menu="wmenu"
      9 else
     10     notify-send -u normal "No wayland compositor used" -i $symbol
     11     exit 1
     12 fi
     13 
     14 # Select all passwords in password store
     15 password_files=$(find ~/.password-store -name '*.gpg' | cut -d "/" -f 5- | sed s/.gpg// )
     16 
     17 # Pipe all passwords into the menu
     18 password=$(printf '%s\n' "${password_files}" | $menu "$@")
     19 
     20 # Exit if store is empty
     21 test -n $password || exit
     22 
     23 # Copy selected password into clipboard
     24 pass show --clip $password