I have a shell script that takes a PDF file as an argument and prints it with additional printer specific options. How can I add this script as a virtual printer that can be selected from the GUI?
The shell script is a manual duplex script that takes a PDF file, prints even pages, gives a user prompt using zenity asking the user to flip the pages and then prints the odd pages.
My current workflow is:
- File -> Print -> Save to file -> tmp.pdf
my_duplex_script tmp.pdfrm tmp.pdf
Is there any way to make it as :
- File -> Print -> my_script_as_virtual_printer
Note: This is on Linux mint 13 cinnamon. I have tried gnome-manual-duplex but it doesn't work for me.
The GUI dialog from which I can print to a PDF file

my_duplex_script
#!/bin/bash
lp_args=
while getopts o: opt
do
case "$opt" in
o) lp_args="$lp_args -o $OPTARG" ;;
\?) echo >&2 Invalid argument; exit 1 ;;
esac
done
shift `expr $OPTIND - 1`
file=$1
page_count=$(pdfinfo "$file" | grep Pages | awk '{print $2}')
is_odd=`expr $page_count % 2`
if [ $is_odd -eq 1 ]
then
#outputting blank
echo | lp -s -t "$file"-blank
fi
#printing even reversed
lp -s -o page-set=even -o outputorder=reverse $lp_args -t "$file"-even "$file"
if zenity --question --text="Flip and reinsert the entire stack when printing has finished." --ok-label="Proceed" --cancel-label="Cancel"
then
#printing odd reversed
lp -s -o page-set=odd -o outputorder=reverse $lp_args -t "$file"-odd "$file"
else
echo >&2 User abort
exit 1
fi
exit 0