From f122223243cbb50fa65d96646bc06f53567fd815 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 25 Feb 2023 13:27:37 +0100 Subject: ... --- accounts/gkleen@sif/default.nix | 2 +- accounts/gkleen@sif/zshrc | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'accounts') diff --git a/accounts/gkleen@sif/default.nix b/accounts/gkleen@sif/default.nix index ed3ba7d8..14e2c9a7 100644 --- a/accounts/gkleen@sif/default.nix +++ b/accounts/gkleen@sif/default.nix @@ -364,7 +364,7 @@ in { weechat wrappedElementDesktop # helvum matrix-synapse-tools.synadm wrappedRocketChatDesktop flakeInputs.deploy-rs.packages.${config.nixpkgs.system}.deploy-rs - sieve-connect pdf-redact-tools gimp inkscape udiskie glab + sieve-connect gimp inkscape udiskie glab ]; file = { diff --git a/accounts/gkleen@sif/zshrc b/accounts/gkleen@sif/zshrc index 8b29b2d3..3136a8f6 100644 --- a/accounts/gkleen@sif/zshrc +++ b/accounts/gkleen@sif/zshrc @@ -113,8 +113,9 @@ dir() { gitWorktree="" # notmuchMsg="" quickserve=false + modifyPDF="" - while getopts ':t:a:s:Sd:ir:wqg:n:' arg; do + while getopts ':t:a:s:Sd:ir:wqg:n:p:' arg; do case $arg in "t") ;; "a") @@ -134,6 +135,7 @@ dir() { "g") gitWorktree=${OPTARG} ;; # "n") notmuchMsg=${OPTARG} ;; "q") quickserve=true ;; + "p") modifyPDF=${OPTARG} ;; *) printf "Invalid option: %s\n" $arg >&2; exit 2 ;; esac done @@ -157,7 +159,15 @@ dir() { gitWorktree="" fi + cleanup() + { + cd ${modifyPDF:h} + [[ -n ${modifyPDF} ]] && nix shell nixos#imagemagick -c convert ${dir}/page-*.png ${modifyPDF} + } + ( + trap cleanup EXIT + cd ${dir} export dir; @@ -165,6 +175,8 @@ dir() { [[ -n ${repoUrl} ]] && git clone -- ${repoUrl} . + [[ -n ${modifyPDF} ]] && templateArchive=${modifyPDF} + if [[ -n ${templateArchive} ]]; then ( archiveFile="" @@ -205,6 +217,10 @@ dir() { cpio --extract --make-directories --no-absolute-filenames -F ${templateArchive} unpack=false ;; + application/pdf) + nix shell nixos#ghostscript nixos#imagemagick -c convert -verbose -density 400 ${templateArchive} page-%0d.png + unpack=false + ;; *) tar -xvaf ${templateArchive} unpack=false -- cgit v1.2.3