dotfiles/config/scripts/cached_pass

29 lines
433 B
Plaintext
Raw Permalink Normal View History

2021-06-11 21:42:55 +02:00
#!/usr/bin/env bash
# TODO Password changed?
set -euo pipefail
if [[ $# -ne 1 ]]
then
echo "Usage: $0 pass-name"
exit 2
fi
name="$1"
BASEDIR="/tmp/cached_pass_${UID}"
mkdir -p "$BASEDIR"
chmod 700 "$BASEDIR"
name_base64="$(echo "$name" | base64)"
file="${BASEDIR}/${name_base64}"
if [ ! -s "${file}" ]
2021-06-11 21:42:55 +02:00
then
2022-01-08 16:34:55 +01:00
notify-send -u low "cached_pass" "Asking to cache: ${name}"
pass ${name} > "${file}"
2021-06-11 21:42:55 +02:00
fi
cat "${file}"