From 4ae6441547afd94eb8826cb2b4f13bc569dd9d56 Mon Sep 17 00:00:00 2001 From: Vineet Kumar Date: Fri, 22 May 2026 18:33:07 -0400 Subject: add kasi-get wrapper around kasi--get for use outside emacs --- README.org | 12 ++++++++++++ kasi.el | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/README.org b/README.org index 848c5cb..0f4dd2e 100644 --- a/README.org +++ b/README.org @@ -33,6 +33,18 @@ the following format: (extra-notes "other stuff to encrypt")) #+end_src +** Accessing From Other Programs +To parse and read the values of the secret files (like ='password= or +='username=), you can run something similar to the following command: +#+begin_src shell + emacsclient -e "(kasi-get \"category/file\" 'password)" | sed 's/^"//; s/"$//' +#+end_src +Unfortunately, I was not able to find a way to make =emacsclient= +print without the return value's type (i.e. without double quotes), +which does make this more clunky for outside Emacs. +Obviously the +solution to this is to just remove them and rewrite those programs in +Emacs Lisp.+ + ** Never Asked Questions (NAQ) *** Why should I use this over any other password manager? Don't. For a serious answer, it's because this uses S-expressions for diff --git a/kasi.el b/kasi.el index bdd8184..9f899e8 100644 --- a/kasi.el +++ b/kasi.el @@ -77,6 +77,10 @@ Two %s are needed for password and username for now.") (insert-file-contents file) (alist-get elem (read (current-buffer)))))) +(defun kasi-get (file elem) + "Prints decrypted element. Wrapper around kasi--get for non-Emacs use." + (kasi--get (format "%s/%s%s" kasi-dir file kasi-extension) elem)) + (defun kasi--totp (file) "Returns current TOTP code from secret file." (let* ((totp-secret (kasi--get file 'totp)) -- cgit v1.2.3