From a9ea85eaa6a8ef6f1a0080db4b1fa38484a6d974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 18 Jan 2020 23:17:09 +0100 Subject: [PATCH] overpdf --- config/scripts/overpdf | 62 +++++++++++++++++++++++++++++++++++++ config/scripts/softwareList | 17 +++++++++- config/shell/commonrc | 1 + 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100755 config/scripts/overpdf diff --git a/config/scripts/overpdf b/config/scripts/overpdf new file mode 100755 index 0000000..51125fc --- /dev/null +++ b/config/scripts/overpdf @@ -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 + + diff --git a/config/scripts/softwareList b/config/scripts/softwareList index 018b269..b9d4627 100755 --- a/config/scripts/softwareList +++ b/config/scripts/softwareList @@ -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 diff --git a/config/shell/commonrc b/config/shell/commonrc index 4d5d4e9..7fdf925 100644 --- a/config/shell/commonrc +++ b/config/shell/commonrc @@ -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