;;; thanos-pass.el --- Pass configuration -*- lexical-binding: t; -*- ;; Copyright (C) 2023 Thanos Apollo ;; Author: Thanos Apollo ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; ╭━━━━┳╮╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━╮╱╱╱╱╱╭╮╭╮╱╱╱╱╱╱╱╱╭━━━╮ ;; ┃╭╮╭╮┃┃╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━╮┃╱╱╱╱╱┃┃┃┃╱╱╱╱╱╱╱╱┃╭━━╯ ;; ╰╯┃┃╰┫╰━┳━━┳━╮╭━━┳━━╮┃┃╱┃┣━━┳━━┫┃┃┃╭━━╮╱╱╱╱┃╰━━┳╮╭┳━━┳━━┳━━╮ ;; ╱╱┃┃╱┃╭╮┃╭╮┃╭╮┫╭╮┃━━┫┃╰━╯┃╭╮┃╭╮┃┃┃┃┃╭╮┃╭━━╮┃╭━━┫╰╯┃╭╮┃╭━┫━━┫ ;; ╱╱┃┃╱┃┃┃┃╭╮┃┃┃┃╰╯┣━━┃┃╭━╮┃╰╯┃╰╯┃╰┫╰┫╰╯┃╰━━╯┃╰━━┫┃┃┃╭╮┃╰━╋━━┃ ;; ╱╱╰╯╱╰╯╰┻╯╰┻╯╰┻━━┻━━╯╰╯╱╰┫╭━┻━━┻━┻━┻━━╯╱╱╱╱╰━━━┻┻┻┻╯╰┻━━┻━━╯ ;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃┃ ;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰╯ ;;; Code: (require 'password-store) (setf password-store-password-length (+ 20 (random 20))) (defun thanos/pass-launcher () "Launch Emacs as a front-end for pass." (interactive) (cl-flet ((pass-autotype (entry) (let ((user (password-store-get-field entry "user")) (pass (password-store-get entry))) (start-process-shell-command "xdotool" nil (if user (format "sleep 0.3 && xdotool getactivewindow type '%s' && xdotool getactivewindow key Tab && xdotool getactivewindow type '%s'" user pass) (format "sleep 0.3 && xdotool getactivewindow type 'thanosapollo' && xdotool getactivewindow key Tab && xdotool getactivewindow type '%s'" pass)))))) (let ((ivy-height 100)) (unwind-protect (with-selected-frame (make-frame '((name . "thanos/pass-launcher") (minibuffer . only) (fullscreen . 0) (undecorated . t) (internal-border-width . 10) (width . 80) (height . 11))) (let* ((choice (completing-read "Choose an action: " '("AUTO" "COPY PASS" "COPY USERNAME" "EDIT" "GENERATE"))) (action (pcase choice ("AUTO" #'pass-autotype) ("COPY PASS" #'password-store-copy) ("COPY USERNAME" #'(lambda (entry) (password-store-copy-field entry "user"))) ("EDIT" #'password-store-edit) ("GENERATE" #'password-store-generate)))) (funcall action (completing-read "Search: " (password-store-list))) (delete-frame))))))) (defun smtp-get-pass () "Get password for smtp." (interactive) (password-store-copy-field "fastmail.com/thanosapollo@fastmail.com" "smtp")) (define-prefix-command 'thanos/pass) (global-set-key (kbd "C-c p") 'thanos/pass) (define-key thanos/pass (kbd "i") 'password-store-insert) (define-key thanos/pass (kbd "e") 'password-store-edit) (define-key thanos/pass (kbd "g") 'password-store-generate) (define-key thanos/pass (kbd "s") 'smtp-get-pass) (defun thanos/app-launcher () "Launch Emacs as an Application Launcher." (interactive) (let ((ivy-height 100)) (unwind-protect (with-selected-frame (make-frame '((name . "thanos/emacs-launcher") (minibuffer . only) (fullscreen . 0) (undecorated . t) (internal-border-width . 10) (width . 80) (height . 11))) (counsel-linux-app) (delete-frame))))) (provide 'thanos-pass) ;;; thanos-pass.el ends here