use correct printer for computer

This commit is contained in:
Chris Cochrun 2024-10-30 10:35:44 -05:00
parent be61aa14fb
commit b16e4847e3
2 changed files with 14 additions and 2 deletions

View file

@ -4751,12 +4751,18 @@ Let's use pdf-tools for a lot better interaction with pdfs.
(pdf-tools-install) (pdf-tools-install)
:config :config
(defun chris/list-printers ()
"Lists the printers that are available for the computer"
(interactive)
(split-string (shell-command-to-string "lpstat -p | awk '{print $2}'")))
(defun chris/print-multi-pdf () (defun chris/print-multi-pdf ()
"Print the pdf in as many copies as needed" "Print the pdf in as many copies as needed"
(interactive) (interactive)
(let* ((copies (completing-read "How many copies: " '("1" "2" "3"))) (let* ((copies (completing-read "How many copies: " '("1" "2" "3")))
(sides (completing-read "Print both sides or one? " '("two sided" "one sided"))) (sides (completing-read "Print both sides or one? " '("two sided" "one sided")))
(pdf-misc-print-program-args `("-o media=Letter" ,(format "-# %s" copies) "-P Home" "-o fit-to-page" (printer (completing-read "Which printer do you want to use?" (chris/list-printers)))
(pdf-misc-print-program-args `("-o media=Letter" ,(format "-# %s" copies) ,(format "-P %s" printer) "-o fit-to-page"
,(if (string= sides "two sided") ,(if (string= sides "two sided")
"-o sides=two-sided-long-edge" "-o sides=two-sided-long-edge"
"")))) ""))))

View file

@ -3456,12 +3456,18 @@ targets."
(pdf-tools-install) (pdf-tools-install)
:config :config
(defun chris/list-printers ()
"Lists the printers that are available for the computer"
(interactive)
(split-string (shell-command-to-string "lpstat -p | awk '{print $2}'")))
(defun chris/print-multi-pdf () (defun chris/print-multi-pdf ()
"Print the pdf in as many copies as needed" "Print the pdf in as many copies as needed"
(interactive) (interactive)
(let* ((copies (completing-read "How many copies: " '("1" "2" "3"))) (let* ((copies (completing-read "How many copies: " '("1" "2" "3")))
(sides (completing-read "Print both sides or one? " '("two sided" "one sided"))) (sides (completing-read "Print both sides or one? " '("two sided" "one sided")))
(pdf-misc-print-program-args `("-o media=Letter" ,(format "-# %s" copies) "-P Home" "-o fit-to-page" (printer (completing-read "Which printer do you want to use?" (chris/list-printers)))
(pdf-misc-print-program-args `("-o media=Letter" ,(format "-# %s" copies) ,(format "-P %s" printer) "-o fit-to-page"
,(if (string= sides "two sided") ,(if (string= sides "two sided")
"-o sides=two-sided-long-edge" "-o sides=two-sided-long-edge"
"")))) ""))))