Set font to Source Code Pro Medium 10.5 across the board
[~bandali/configs] / .local / bin / passmenu
1 #!/usr/bin/env bash
2
3 # Copyright (c) 2014-2021 password-store contributors
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17
18 shopt -s nullglob globstar
19
20 typeit=0
21 if [[ $1 == "--type" ]]; then
22 typeit=1
23 shift
24 fi
25
26 if [[ -n $WAYLAND_DISPLAY ]]; then
27 dmenu=dmenu-wl
28 xdotool="ydotool type --file -"
29 elif [[ -n $DISPLAY ]]; then
30 dmenu=dmenu
31 xdotool="xdotool type --clearmodifiers --file -"
32 else
33 echo "Error: No Wayland or X11 display detected" >&2
34 exit 1
35 fi
36
37 prefix=${PASSWORD_STORE_DIR-~/.password-store}
38 password_files=( "$prefix"/**/*.gpg )
39 password_files=( "${password_files[@]#"$prefix"/}" )
40 password_files=( "${password_files[@]%.gpg}" )
41
42 password=$(printf '%s\n' "${password_files[@]}" | "$dmenu" "$@")
43
44 [[ -n $password ]] || exit
45
46 if [[ $typeit -eq 0 ]]; then
47 pass show -c "$password" 2>/dev/null
48 else
49 pass show "$password" | { IFS= read -r pass; printf %s "$pass"; } | $xdotool
50 fi