overpdf
This commit is contained in:
parent
ec6312f506
commit
a9ea85eaa6
62
config/scripts/overpdf
Executable file
62
config/scripts/overpdf
Executable file
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Utility to write over a PDF file pages
|
||||
|
||||
# TODO Inkscape vodoo: Put the original in its own layer and skip when merging
|
||||
|
||||
orig_path="$1"
|
||||
|
||||
orig_dir="$(dirname "$orig_path")"
|
||||
orig_file="$(basename "$orig_path")"
|
||||
orig_ext="${orig_file##*.}"
|
||||
orig_name="${orig_file%.*}"
|
||||
|
||||
wdir_file="${orig_name}_src.${orig_ext}"
|
||||
wdir_path="${orig_dir}/${wdir_file}"
|
||||
|
||||
if [ -d "$wdir_path" ]
|
||||
then
|
||||
echo "Source directory $wdir_path found"
|
||||
ls "${wdir_path}/${orig_name}_"*"_og.pdf" | while read page_orig_path
|
||||
do
|
||||
page_stmp_svg="$(echo "$page_orig_path" | sed 's|_og\.pdf$|_fg\.svg|')"
|
||||
page_stmp_pdf="$(echo "$page_orig_path" | sed 's|_og\.pdf$|_fg\.pdf|')"
|
||||
page_fin_pdf="$(echo "$page_orig_path" | sed 's|_og\.pdf$|_fin\.pdf|')"
|
||||
if [ -f "$page_stmp_svg" ]
|
||||
then
|
||||
echo "Processing $page_orig_path (applying stamp)"
|
||||
inkscape "$page_stmp_svg" --export-pdf "$page_stmp_pdf"
|
||||
pdftk "$page_orig_path" stamp "$page_stmp_pdf" output "$page_fin_pdf"
|
||||
else
|
||||
echo "Processing $page_orig_path (copying)"
|
||||
cp "$page_orig_path" "$page_fin_pdf"
|
||||
fi
|
||||
done
|
||||
echo "Merging everything back to ${orig_path}."
|
||||
pdftk "${wdir_path}/${orig_name}_"*"_fin.pdf" output "$orig_path"
|
||||
echo "Deleting temporary files."
|
||||
rm "${wdir_path}/${orig_name}_"*"_fin.pdf" "${wdir_path}/${orig_name}_"*"_fg.pdf"
|
||||
echo "Done."
|
||||
elif [ -f "$orig_path" ]
|
||||
then
|
||||
if [ "$(file --mime-type --brief $orig_path)" != "application/pdf" ]
|
||||
then
|
||||
echo "${orig_path}: not a PDF file"
|
||||
exit 1
|
||||
fi
|
||||
echo "Creating source directory $wdir_path with original pages and template SVGs"
|
||||
mkdir "$wdir_path"
|
||||
pdftk "$orig_file" burst output "${wdir_path}/${orig_name}_%03d_og.pdf"
|
||||
ls "${wdir_path}/${orig_name}_"*"_og.pdf" | while read page_orig_path
|
||||
do
|
||||
page_stmp_svg="$(echo "$page_orig_path" | sed 's|_og\.pdf$|_fg\.svg|')"
|
||||
echo "Processing $page_orig_path"
|
||||
inkscape "$page_orig_path" --export-plain-svg "$page_stmp_svg"
|
||||
done
|
||||
echo "Done. Make sure to edit in a a new layer in Inkscape and hide the original one."
|
||||
else
|
||||
echo "${orig_path}: no such file or directory"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
|
@ -56,6 +56,10 @@ uservar INSTALL_DOCUMENT "Create documents?"
|
|||
uservar INSTALL_IMAGE "Do image editing?"
|
||||
uservar INSTALL_MUSIC "Play/edit music?"
|
||||
uservar INSTALL_VIDEO "Play/edit videos?"
|
||||
if $INSTALL_GUI
|
||||
then
|
||||
uservar INSTALL_WINE "Run Windows applications?"
|
||||
fi
|
||||
|
||||
echo "(you can change those answers later in $CONFIG_FILE)"
|
||||
|
||||
|
@ -277,6 +281,16 @@ then
|
|||
fi
|
||||
fi
|
||||
|
||||
if $INSTALL_WINE
|
||||
then
|
||||
# TODO Add multilib repo and pacman -Sy
|
||||
i wine # Wine
|
||||
i wine-gecko # Wine Internet Explorer
|
||||
i wine-mono # Wine .NET
|
||||
i mono # Mono .NET
|
||||
i lib32-libpulse # Sound for Wine with pulseaudio
|
||||
fi
|
||||
|
||||
# Desktop environment
|
||||
if $INSTALL_GUI
|
||||
then
|
||||
|
@ -292,7 +306,9 @@ then
|
|||
i gedit # Visual editor (just in case)
|
||||
i feh # Background / Image viewer
|
||||
i zathura && i zathura-pdf-mupdf # PDF viewer
|
||||
i ttf-dejavu # Font
|
||||
i ttf-twemoji # Emoji fonts
|
||||
i adobe-source-han-sans-otc-fonts # Chinese/Japanese/Korean fonts
|
||||
i sox # For beeps and stuff
|
||||
i meld # For comparison
|
||||
|
||||
|
@ -313,7 +329,6 @@ then
|
|||
i xclip # Copy/paste
|
||||
i lemonbar-xft-git lemonbar # Bottom bar
|
||||
i autorandr # Multiple screen configurations
|
||||
i ttf-dejavu # Font
|
||||
i keynav-enhanced keynav # Use mouse with keyboard
|
||||
i pacmixer # To change PA volumes
|
||||
i sct # Red filter # TODO Autocompile
|
||||
|
|
|
@ -31,4 +31,5 @@ FZF_COMPLETION_OPTS="${FZF_CTRL_T_OPTS}"
|
|||
## FUNCTIONS
|
||||
|
||||
## MISC
|
||||
[ -f $HOME/.local/share/broot/launcher/bash/1 ] && . $HOME/.local/share/broot/launcher/bash/1
|
||||
trysource ~/.config/gscripts/gprofile
|
||||
|
|
Loading…
Reference in a new issue