From b16e4847e37ebff5ecbf9080e1a0f705983fc890 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Wed, 30 Oct 2024 10:35:44 -0500 Subject: [PATCH] use correct printer for computer --- README.org | 8 +++++++- init.el | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.org b/README.org index fc3982c5..d5b75130 100644 --- a/README.org +++ b/README.org @@ -4751,12 +4751,18 @@ Let's use pdf-tools for a lot better interaction with pdfs. (pdf-tools-install) :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 () "Print the pdf in as many copies as needed" (interactive) (let* ((copies (completing-read "How many copies: " '("1" "2" "3"))) (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") "-o sides=two-sided-long-edge" "")))) diff --git a/init.el b/init.el index fcae7feb..3e894bb5 100644 --- a/init.el +++ b/init.el @@ -3456,12 +3456,18 @@ targets." (pdf-tools-install) :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 () "Print the pdf in as many copies as needed" (interactive) (let* ((copies (completing-read "How many copies: " '("1" "2" "3"))) (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") "-o sides=two-sided-long-edge" ""))))