I am trying to decrypt a gpg file inside a script. When I run gpg -d file.gpg
in the terminal, I get prompted to enter the password in a curses dialog box. But when I run a script containing that line, I get "gpg: decryption failed: No secret key", or a silent failure if not run from an interactive terminal.
Ideally, if gpg is trying to run from a non-interactive shell (I think that's the word for what I mean but I'm not sure - basically if it's run from a script), when I'm running X, then I would like it to open a terminal window running pinentry-curses
.
If I set my pinentry program to run with qt or gtk, then a graphical window pops up every time, no matter where it comes from. That's the kind of behaviour I'd like to replicate - I just don't want it to depend on qt or gtk.