dotfiles/hm/scripts/cached_pass

31 lines
495 B
Plaintext
Raw Normal View History

#!/usr/bin/env nix-shell
#! nix-shell -i bash
#! nix-shell -p bash pass libnotify
2021-06-11 21:42:55 +02:00
# 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}"