summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVineet Kumar <git@vineetk.net>2026-05-22 18:33:07 -0400
committerVineet Kumar <git@vineetk.net>2026-05-23 19:30:28 -0400
commit4ae6441547afd94eb8826cb2b4f13bc569dd9d56 (patch)
tree72aaa14b6c889799000f10a9fb01a9829122dc26
parentfad20e27b359f216405aad0e0f0cb7d329bc4817 (diff)
add kasi-get wrapper around kasi--get for use outside emacs
-rw-r--r--README.org12
-rw-r--r--kasi.el4
2 files changed, 16 insertions, 0 deletions
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:
33 (extra-notes "other stuff to encrypt")) 33 (extra-notes "other stuff to encrypt"))
34#+end_src 34#+end_src
35 35
36** Accessing From Other Programs
37To parse and read the values of the secret files (like ='password= or
38='username=), you can run something similar to the following command:
39#+begin_src shell
40 emacsclient -e "(kasi-get \"category/file\" 'password)" | sed 's/^"//; s/"$//'
41#+end_src
42Unfortunately, I was not able to find a way to make =emacsclient=
43print without the return value's type (i.e. without double quotes),
44which does make this more clunky for outside Emacs. +Obviously the
45solution to this is to just remove them and rewrite those programs in
46Emacs Lisp.+
47
36** Never Asked Questions (NAQ) 48** Never Asked Questions (NAQ)
37*** Why should I use this over any other password manager? 49*** Why should I use this over any other password manager?
38Don't. For a serious answer, it's because this uses S-expressions for 50Don'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.")
77 (insert-file-contents file) 77 (insert-file-contents file)
78 (alist-get elem (read (current-buffer)))))) 78 (alist-get elem (read (current-buffer))))))
79 79
80(defun kasi-get (file elem)
81 "Prints decrypted element. Wrapper around kasi--get for non-Emacs use."
82 (kasi--get (format "%s/%s%s" kasi-dir file kasi-extension) elem))
83
80(defun kasi--totp (file) 84(defun kasi--totp (file)
81 "Returns current TOTP code from secret file." 85 "Returns current TOTP code from secret file."
82 (let* ((totp-secret (kasi--get file 'totp)) 86 (let* ((totp-secret (kasi--get file 'totp))