Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 20 additions & 24 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ echo

if [ $(logname) == root ]; then
echo "Don't run this as root"
echo ""
echo
exit 1
fi
if [ $(whoami) != root ]; then
echo "Use sudo to become root."
echo ""
echo
exit 1
fi

Expand All @@ -22,18 +22,18 @@ fi
# all_users=$(awk -F: '($3>=1000)&&($1!="nobody"){print $1}' /etc/passwd)

check_dependencies() {
local missing=0
for cmd in pdfinfo zenity lp seq paste awk grep; do
if ! command -v "$cmd" >/dev/null 2>&1; then
LOG "Error: Required command '$cmd' not found."
missing=1
fi
done
if (( missing )); then
echo "Missing required dependencies. See $LogFile for details." >&2
exit 1
local missing=0
for cmd in pdfinfo zenity lp seq paste awk grep; do
if ! command -v "$cmd" > /dev/null 2>&1; then
echo "Error: Required command '$cmd' not found."
missing=1
fi
echo "Finished dependency check."
done
if ((missing)); then
echo "Missing required dependencies." >&2
exit 1
fi
echo "Finished dependency check."
}

check_dependencies
Expand All @@ -44,9 +44,8 @@ echo "These are your installed printers:"
echo
declare printers_array
i=0
for p in $all_printers
do
i=$(( $i + 1 ))
for p in $all_printers; do
i=$(($i + 1))
echo $i. $p
printers_array[$i]=$p
done
Expand All @@ -59,8 +58,7 @@ first_printer=${printers_array[$chosen_printer]}

function setup_duplexer {
first_printer=$1
if [ -z "$first_printer" ]
then
if [ -z "$first_printer" ]; then
echo "No printer submitted. You trickster!"
exit 1
else
Expand Down Expand Up @@ -117,7 +115,7 @@ function setup_duplexer {

cp -praf /etc/cups/ppd/$first_printer.ppd /etc/cups/ppd/Manual_Duplexer_$first_printer.ppd

# sed -i 's/"0 hpcups"/"duplex_print_filter"/g' /etc/cups/ppd/Manual_Duplexer_$first_printer.ppd
# sed -i 's/"0 hpcups"/"duplex_print_filter"/g' /etc/cups/ppd/Manual_Duplexer_$first_printer.ppd
sed -i '/^*cupsFilter/d' /etc/cups/ppd/Manual_Duplexer_$first_printer.ppd

echo '*cupsFilter: "application/pdf 0 duplex_print_filter"' >> /etc/cups/ppd/Manual_Duplexer_$first_printer.ppd
Expand All @@ -126,7 +124,6 @@ function setup_duplexer {
echo '*cupsFilter: "application/vnd.cups-raster 0 duplex_print_filter"' >> /etc/cups/ppd/Manual_Duplexer_$first_printer.ppd
echo '*cupsFilter: "application/vnd.cups-pdf 0 duplex_print_filter"' >> /etc/cups/ppd/Manual_Duplexer_$first_printer.ppd


sleep 1

service cups restart &> /dev/null
Expand Down Expand Up @@ -154,13 +151,12 @@ echo
echo "(Y/N) followed by [ENTER]:"
read approve

if [ $approve == "Y" ]
then
if [ $approve == "Y" ]; then
echo
echo
echo
setup_duplexer $first_printer
else
setup_duplexer $first_printer
else
echo
echo "Nothing was changed. Maybe use capital Y ?"
echo
Expand Down
Binary file removed manual_duplex_linux_1.0.tar.gz
Binary file not shown.
Loading