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/zshrc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'accounts/gkleen@sif/zshrc') 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