Skip to content

Commit

Permalink
Use screenshotcapture on mac (#7)
Browse files Browse the repository at this point in the history
Use screenshotcapture on mac
  • Loading branch information
volrath authored Jul 13, 2019
2 parents 1819cd8 + 3e571fb commit 04998c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and Linux, YMMV.
Shares all dependencies with `pass` and `pass-otp`, and introduces these for SS
handling and QR code generation:

- imagemagick (--with-x11 support)
- imagemagick (--with-x11 support. Not required for Mac.)
- zbar-tools
- qrencode

Expand Down
9 changes: 7 additions & 2 deletions password-store-otp.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
:type '(choice (const :tag "Off" nil)
(file :tag "Expandable file name")))

(defun password-store-otp--get-screenshot-executable ()
"Return the name of the executable that should be used to take screenshots."
(if (eq window-system 'mac) "screencapture" "import"))

(defun password-store-otp--otpauth-lines (lines)
"Return from LINES those that are OTP urls."
(seq-filter (lambda (l) (string-prefix-p "otpauth://" l))
Expand Down Expand Up @@ -164,8 +168,9 @@ primary \"pass otp\" command line verb."
(defun password-store-otp-append-from-image (entry)
"Check clipboard for an image and scan it to get an OTP URI, append it to ENTRY."
(interactive (list (password-store-otp-completing-read)))
(let ((qr-image-filename (password-store-otp--get-qr-image-filename entry)))
(when (not (zerop (call-process "import" nil nil nil qr-image-filename)))
(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)))
(error "Couldn't get image from clipboard"))
(with-temp-buffer
(condition-case nil
Expand Down

0 comments on commit 04998c8

Please sign in to comment.