t-8ch / pinentry-bemenu

Pinentry based on bemenu
GNU General Public License v3.0
49 stars 3 forks source link

Usage instructions #8

Closed concatime closed 2 years ago

concatime commented 2 years ago

Hi. Is it possible to provide instructions on how to use it? Sure, pinentry-program /usr/local/bin/pinentry-bemenu in gpg-agent.conf should work, but it assumes that the desktop environment is ALWAYS set. What I want (if possible), is a more dynamic approach. Use pinentry-bemenu when Sway is running, and fallback to pinentry (pinentry-curses or pinentry-tty) (say, ssh session). Is it possible? I don’t master gpg yet, so bear with me :)

concatime commented 2 years ago

For now, I have in my ~/.profile:

PINENTRY=$(command -v pinentry 2>/dev/null)
eval $(gpg-agent --daemon --enable-ssh-support --pinentry-program="${PINENTRY:-/dev/null}")
unset PINENTRY

Is it possible change the pinentry program of a running gpg-agent from a command? If yes, I can add the command to ~/.config/sway/config.d/.... This way, when Sway starts, it would change the pinentry program to pinentry-bemenu.

t-8ch commented 2 years ago

@concatime pinenetry-bemenu should behave the same as the official graphical pinentry tools, which also just assume they run in a graphical environment. I don't think any dynamic configuration is possible. Instead you could write a wrapper scripts that implements any logic you want and executes the correct pinentry program.

concatime commented 2 years ago

Oh well, if dynamic configuration isn’t possible, the static one should. I created a file called ~/.config/sway/config.d/10-gpg_pinentry_bemenu with:

exec sh -c 'gpgconf --kill gpg-agent && gpg-agent --daemon --enable-ssh-support --pinentry-program="$(command -v pinentry-bemenu)"'

Also, it would be nice if you add a selection screenshot in README of the end result.

t-8ch commented 2 years ago

You can also create ${XDG_CONFIG_HOME:-$HOME/.config}"/pinentry/preexec and that will be used by /usr/bin/pinentry.

t-8ch commented 2 years ago

I also added a screenshot. It's a bit small because it show the whole screen, but I think it's important to see how fits into the rest of the environment.