Lazily retry lichess token fetch; demand-load lichess package
gpg-agent may not have a cached passphrase yet when the top-level setq runs at Emacs startup, so a cold agent makes 'pass' fail silently (stderr redirected) and leaves lichess-token permanently empty for the session. Retry the fetch right before each use instead of only once at startup.
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
(use-package lichess
|
(use-package lichess
|
||||||
|
:demand t
|
||||||
:init
|
:init
|
||||||
(defun azos/chess/open ()
|
(defun azos/chess/open ()
|
||||||
"Open lichess in its dedicated \"chess\" tab."
|
"Open lichess in its dedicated \"chess\" tab."
|
||||||
|
|||||||
@@ -295,6 +295,21 @@ Redirect stderr away so only the token itself is ever captured.
|
|||||||
(string-trim (shell-command-to-string "pass lichess.org/token 2>/dev/null | head -1")))
|
(string-trim (shell-command-to-string "pass lichess.org/token 2>/dev/null | head -1")))
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
|
=gpg-agent= may not have a cached passphrase yet when the =setq= above
|
||||||
|
runs at Emacs startup, in which case =pass= fails silently (stderr is
|
||||||
|
redirected away) and =lichess-token= is left as =""=. Retry the fetch
|
||||||
|
lazily right before each actual use, so a cold agent at startup
|
||||||
|
doesn't permanently wedge the token for the rest of the session.
|
||||||
|
|
||||||
|
#+begin_src emacs-lisp
|
||||||
|
(with-eval-after-load 'lichess
|
||||||
|
(advice-add 'lichess-token :before
|
||||||
|
(lambda ()
|
||||||
|
(when (string-empty-p lichess-token)
|
||||||
|
(setq lichess-token
|
||||||
|
(string-trim (shell-command-to-string "pass lichess.org/token 2>/dev/null | head -1")))))))
|
||||||
|
#+end_src
|
||||||
|
|
||||||
** Beacon Remote Jobs
|
** Beacon Remote Jobs
|
||||||
|
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
|||||||
Reference in New Issue
Block a user