Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add KDE spectacle in the list of screenshot executables to use #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions password-store-otp.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@

(defun password-store-otp--get-screenshot-executable ()
"Return the name of the executable that should be used to take screenshots."
(if (and (eq system-type 'darwin)
(executable-find "screencapture")) "screencapture" "import"))
(cond
((and (eq system-type 'darwin) (executable-find "screencapture")) "screencapture")
((executable-find "spectacle") "spectacle")
(t "import")))

(defun password-store-otp--get-screenshot-executable-args (screenshot-executable)
"Return the args needed for SCREENSHOT-EXECUTABLE to make it save to a given file."
(cond
((equal screenshot-executable "spectacle") '("-n" "-b" "-w" "-o"))
(t nil)))

(defun password-store-otp--otpauth-lines (lines)
"Return from LINES those that are OTP urls."
Expand Down Expand Up @@ -171,7 +179,10 @@ primary \"pass otp\" command line verb."
(interactive (list (password-store-otp-completing-read)))
(let ((qr-image-filename (password-store-otp--get-qr-image-filename entry))
(screenshot-executable (password-store-otp--get-screenshot-executable)))
(when (not (zerop (call-process screenshot-executable nil nil nil qr-image-filename)))
(when (not (zerop (apply #'call-process
(append (list screenshot-executable nil nil nil)
(password-store-otp--get-screenshot-executable-args screenshot-executable)
(list qr-image-filename)))))
(error "Couldn't get image from clipboard"))
(with-temp-buffer
(condition-case nil
Expand Down