2022-10-18 21:45:20 -03:00
|
|
|
{ pkgs, ... }:
|
2022-08-08 21:16:45 -03:00
|
|
|
pkgs.writeShellScriptBin "_gpg-unlock" ''
|
|
|
|
${pkgs.gnupg}/bin/gpg-connect-agent reloadagent /bye
|
|
|
|
|
2022-11-30 14:39:55 -03:00
|
|
|
set -e
|
2022-08-08 21:16:45 -03:00
|
|
|
|
|
|
|
test -f "$HOME/.config/.preset-password" || {
|
|
|
|
notify-send "No preset password found"
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get_keygrip() {
|
|
|
|
${pkgs.gnupg}/bin/gpg --list-secret-keys --with-keygrip |
|
|
|
|
awk '
|
|
|
|
/^ssb/ {
|
|
|
|
ssb=1
|
|
|
|
}
|
|
|
|
/Keygrip/{
|
|
|
|
if (ssb) print $3
|
|
|
|
}'
|
|
|
|
}
|
|
|
|
|
|
|
|
keygrip=$(get_keygrip)
|
|
|
|
|
|
|
|
test -n "$keygrip" || exit 0
|
|
|
|
|
|
|
|
cat "$HOME/.config/.preset-password" |
|
|
|
|
base64 -d |
|
|
|
|
${pkgs.gnupg}/libexec/gpg-preset-passphrase --preset "$keygrip"
|
|
|
|
''
|