Interim fix, no gpg key
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
enable = true;
|
||||
signing = {
|
||||
key = "6D17E295C70E2674";
|
||||
signByDefault = true;
|
||||
signByDefault = false;
|
||||
};
|
||||
settings = {
|
||||
credential.helper = "!pass-git-helper $@";
|
||||
|
||||
@@ -333,6 +333,42 @@ With prefix ARG, prompt for a pattern then select from matches."
|
||||
(define-key azos/roam-keymap (kbd "B") #'azos/roam/backup)
|
||||
#+end_src
|
||||
|
||||
** Printing
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
(defun azos/print-buffer (&optional arg)
|
||||
"Print the current buffer.
|
||||
For image/PDF/doc buffers, sends the file path to lp directly.
|
||||
For text buffers, uses lpr-buffer.
|
||||
With C-u, interactively prompt for scaling, B&W, and orientation options."
|
||||
(interactive "P")
|
||||
(let* ((image-p (derived-mode-p 'image-mode 'pdf-view-mode 'doc-view-mode))
|
||||
(scale (when arg (y-or-n-p "Fit to page? ")))
|
||||
(bw (when arg (y-or-n-p "Black and white? ")))
|
||||
(landscape (when (and arg image-p) (y-or-n-p "Landscape? ")))
|
||||
(lp-opts (concat
|
||||
(when scale " -o fit-to-page")
|
||||
(when bw " -o print-color-mode=monochrome")
|
||||
(when landscape " -o landscape"))))
|
||||
(if image-p
|
||||
(if buffer-file-name
|
||||
(progn
|
||||
(shell-command
|
||||
(concat "lp" lp-opts " " (shell-quote-argument buffer-file-name)))
|
||||
(message "Sent %s to printer%s%s%s."
|
||||
(file-name-nondirectory buffer-file-name)
|
||||
(if scale " [scaled]" "")
|
||||
(if bw " [B&W]" "")
|
||||
(if landscape " [landscape]" "")))
|
||||
(error "Buffer has no associated file"))
|
||||
(let ((lpr-switches
|
||||
(append lpr-switches
|
||||
(when bw '("-o print-color-mode=monochrome")))))
|
||||
(lpr-buffer)))))
|
||||
|
||||
(define-key azos/global-minor-mode/open-keymap (kbd "P") #'azos/print-buffer)
|
||||
#+end_src
|
||||
|
||||
* Provide
|
||||
|
||||
#+begin_src emacs-lisp
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
{...}: {
|
||||
config.flake.modules.nixos.printing = {
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
webpFilter = pkgs.writeShellScript "webptopdf" ''
|
||||
if [ $# -ge 6 ]; then
|
||||
INPUT="$6"
|
||||
TMPFILE=""
|
||||
else
|
||||
TMPFILE=$(mktemp /tmp/cups-webp-XXXXXX.webp)
|
||||
cat > "$TMPFILE"
|
||||
INPUT="$TMPFILE"
|
||||
fi
|
||||
TMPOUT=$(mktemp /tmp/cups-webp-XXXXXX.pdf)
|
||||
${pkgs.imagemagick}/bin/magick "$INPUT" "$TMPOUT"
|
||||
cat "$TMPOUT"
|
||||
rm -f "$TMPOUT"
|
||||
[ -n "$TMPFILE" ] && rm -f "$TMPFILE"
|
||||
'';
|
||||
|
||||
webpCupsMime = pkgs.runCommand "webp-cups-mime" {} ''
|
||||
mkdir -p $out/lib/cups/filter $out/share/cups/mime
|
||||
cp ${webpFilter} $out/lib/cups/filter/webptopdf
|
||||
chmod +x $out/lib/cups/filter/webptopdf
|
||||
echo 'image/webp webp string(0,"RIFF") string(8,"WEBP")' > $out/share/cups/mime/webp.types
|
||||
echo 'image/webp application/pdf 0 webptopdf' > $out/share/cups/mime/webp.convs
|
||||
'';
|
||||
in {
|
||||
options.azos.printing.enable = lib.mkOption {
|
||||
default = false;
|
||||
example = true;
|
||||
type = lib.types.bool;
|
||||
};
|
||||
|
||||
config = lib.mkIf config.azos.printing.enable {
|
||||
services.printing = {
|
||||
enable = true;
|
||||
drivers = [pkgs.hplip webpCupsMime];
|
||||
};
|
||||
|
||||
environment.systemPackages = [pkgs.hplip];
|
||||
|
||||
services.avahi = {
|
||||
enable = true;
|
||||
nssmdns4 = true;
|
||||
openFirewall = true;
|
||||
};
|
||||
|
||||
users.users.aner.extraGroups = ["lp"];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -58,3 +58,5 @@ c.fonts.hints = "bold 13px 'LiberationMono'"
|
||||
#Set highdpi
|
||||
c.qt.highdpi = True
|
||||
c.zoom.default = 70
|
||||
|
||||
c.qt.args = ['renderer-process-limit=6']
|
||||
|
||||
Reference in New Issue
Block a user