#!/bin/bash
################################################
#                                              #
#  autoprint-client.sh                         #
#  Copies files to autoprint/tmp folder and    #
#  when finished, move them to print folder    #
#                                              #
#                                 version 1.1  #
################################################

# Path to print folder after copy is completed
printdir="/autoprint/print"

# Path to tmp folder before it's moved to autoprint/print folder
tmpdir="/autoprint/tmp"

# Notify popup when copy is completed (yes/no)
notify="yes"



############################################################################################
########################  CHANGE AT OWN RISK BELOW THIS LINE  ##############################
############################################################################################

if [ "$1" = "" ]; then
  echo -e "\n Nemo script: Copy a file to AutoPrint folder."
  echo -e " Usage:  $(basename $0) </path/file> \n"
  exit
fi

filename=$(basename $1)

cp "$1" "$tmpdir"
mv "$tmpdir/$filename" "$printdir"

if [ "$notify" = "yes" ]; then
  notify-send --urgency=normal "AutoPrint:  $filename  is copied to  $printdir "
fi
