diff options
| author | Thomas Bracht Laumann Jespersen <t@laumann.xyz> | 2026-08-12 06:48:25 +0200 |
|---|---|---|
| committer | Thomas Bracht Laumann Jespersen <t@laumann.xyz> | 2026-08-12 06:48:25 +0200 |
| commit | 4d00d65bd0c4c6c2283029875128757b0d6b6dbd (patch) | |
| tree | 7ed0dcd255fee33d9d839f108029023625284a64 | |
| parent | d352bae21b6e14f6fe8f81b22062570d2c6d6add (diff) | |
Me write pretty one day.
| -rw-r--r-- | site/emacs-pinentry.md | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/site/emacs-pinentry.md b/site/emacs-pinentry.md index 609a8ee..f7da79c 100644 --- a/site/emacs-pinentry.md +++ b/site/emacs-pinentry.md @@ -13,48 +13,46 @@ notifications when gpg triggers pinentry to prompt for a passphrase.</em> I have been expanding my Emacs usage, reading manuals and tinkering with my configuration, and recently managed to address a small -annoyance with Emacs as pinentry dialog. I have Emacs set up as the -pinentry dialog +annoyance with Emacs as pinentry dialog. When GPG needs to prompt for +a passphrase, I have Emacs set up as the pinentry dialog <sidenote name="app-emacs-pinentry"><https://github.com/ueno/pinentry-el>, <https://packages.gentoo.org/packages/app-emacs/pinentry></sidenote> -so when GPG needs to prompt for a passphrase, a little -dialog buffer pops up in Emacs. This works great when I am already -working in Emacs, but there's a small hitch when I run a command in a -terminal _outside_ of Emacs and GPG needs to call pinentry. -<marginnote name="pinentry">Examples are `ssh` to connect someplace as -I have GPG configured to provide an SSH key, or `git commit ---gpg-sign`</marginnote> -In this situation, a prompt appears in Emacs, but there's no -indication in the terminal that something is happening elsewhere. In the moment, it can be difficult to ascertain whether the -command is quietly running in the background or just paused waiting -for the pinentry prompt to be addressed. There's some uncertainty in -the situation and it has happened fairly often that the command has -failed due to the pinentry prompt timing out and I completely -missed the active prompt. +where a little buffer pops up for me to enter my passphrase. This +works great when I am already working in Emacs, but there's an issue +when I run a command in a terminal _outside_ of Emacs and GPG needs to +call pinentry: +<marginnote name="pinentry">Examples of commands I sometimes in a +terminal are `ssh` to connect someplace as I have GPG configured to +provide an SSH key, or `git commit --gpg-sign`.</marginnote> +a prompt does appear in Emacs, but there's no indication in the +terminal that something is happening elsewhere. In the moment, it can +be difficult to ascertain whether the command is still running or +paused waiting for the pinentry prompt to be addressed. +It happened frequently that a command failed because I missed the +pinentry prompt and it timed out, and that has been bothering me. -What I wanted is to be notified somehow that Emacs is waiting for a -passphrase entry. At first, I looked for options or hooks in GPG to -print a little notice when pinentry is called but I have yet to find -something like that. Then I discovered `(notifications-notify)` +What I wanted was some indication that Emacs is waiting for a passphrase +entry. At first, I looked for options or hooks in GPG to print a +little notice when pinentry is called but I have yet to find something +like that. Then I discovered `(notifications-notify)` <sidenote name="notifications-notify"><https://www.gnu.org/software/emacs/manual/html_node/elisp/Desktop-Notifications.html></sidenote> -in Emacs that can be used to generate a desktop notification and +that can be used to generate a desktop notification and started looking at pinentry.el to see if there was a place to hook in and generate notifications. <marginnote name="pinentry-mode-hook">You may already be thinking -_"but, but, but the pinentry-mode is implicitly defined, just hook into that!"_ +_"but pinentry-mode implicitly defines a hook, just use that!"_ I didn't know that at the time, but I'll get there!</marginnote> I didn't find any _explicitly_ defined hooks for this purpose though. I briefly considered patching the pinentry.el sources and -simply inject the notification code. Gentoo has a great feature called +simply inject the notification code. Gentoo has a great feature usually referred to as _user patches_ <sidenote name="gentoo-patching"><https://wiki.gentoo.org/wiki//etc/portage/patches></sidenote> -that make patching sources quite trivial. Before I got so far I -discovered `(advice-add)` +that makes patching sources quite trivial. Before I got that far though I +found `(advice-add)` <sidenote -name="advice-add"><https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html> -— sort of Gentoo user patches, but for elisp functions?</sidenote> +name="advice-add"><https://www.gnu.org/software/emacs/manual/html_node/elisp/Advising-Functions.html></sidenote> that essentially allows hooking into _any_ function and eventually came up with this: |
