Subversion Repositories Projects

Rev

Rev 96 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
96 dhylands 1
#!/bin/bash
213 dhylands 2
###########################################################################
3
#
4
# Front end for enscript
5
#
6
###########################################################################
96 dhylands 7
 
213 dhylands 8
###########################################################################
9
#
10
# Usage - print the usage message for this script
11
#
12
###########################################################################
13
 
14
function Usage
15
{
16
   cat <<EOF
17
Usage: ${scriptName} [-12epntv][-o out-dev] file ...
18
Where:
19
   -1 Print 1 column
20
   -2 Print 2 columns (default)
21
   -e Only echo the enscript command, don't execute it
22
   -h Print this help page
23
   -n Print in 'normal', 1-Col mode
24
   -o Select output device (default=${PRT_OUTDEV})
25
   -p Select pages to print (s-e, -e, s-, page, odd, even)
26
      s-e  Prints pages from s to e
27
      s-   Prints pages from s to the end
28
      -e   Prints pages from the start to e
29
      page Prints a particular page
30
      even Prints even pages
31
      odd  Prints odd pages
32
   -t Print on tabloid paper
33
   -v Verbose mode
34
EOF
35
}
36
 
37
###########################################################################
38
 
39
scriptName=$(basename $0)
40
 
41
if [ -z "${PRT_OUTDEV}" ]
42
then
43
   echo "PRT_OUTDEV environment variable should be set to the name of the"
44
   echo "printer to use."
45
   exit 1
46
fi
47
 
48
TAB='4'
49
FONT='Courier6'
50
COLUMNS='2'
51
 
52
SIMPLEX=
53
DUPLEX='--file-align=2 --setpagedevice=Duplex:true'
54
PLEX=${DUPLEX}
55
 
56
LETTER_SIZE='[612 792]'
57
TABLOID_SIZE='[792 1224]'
58
 
59
MEDIA='Letter'
60
PAGESIZE=${LETTER_SIZE}
61
 
62
# Tumble:true does short edge binding, Tumble:false does long edge binding.
63
 
64
LONG_EDGE_BINDING='--setpagedevice=Tumble:false'
65
SHORT_EDGE_BINDING='--setpagedevice=Tumble:true'
66
 
67
ORIENT="--landscape ${SHORT_EDGE_BINDING}"
68
PAGE_RANGE=''
69
 
70
verbose=false
71
execCmd=true
72
 
73
OPTS1='--line-numbers --borders --pretty-print --fancy-header=dhylands'
74
 
75
while getopts ":12eho:p:ntv" opt
76
do
77
   case ${opt} in
78
 
79
      1)
80
         COLUMNS='1'
81
         ;;
82
 
83
      2)
84
         COLUMNS='2'
85
         ;;
86
 
87
      e)
88
         execCmd=false
89
         verbose=true
90
         ;;
91
 
92
      h)
93
         Usage
94
         exit 0
95
         ;;
96
 
97
      o)
98
         PRT_OUTDEV=${OPTARG}
99
         ;;
100
 
101
      p)
102
         PAGE_RANGE="${PAGE_RANGE} --pages=${OPTARG}"
103
         ;;
104
 
105
      n)
106
         MEDIA='Letter'
107
         PAGESIZE=${LETTER_SIZE}
108
         ORIENT="--portrait ${LONG_EDGE_BINDING}"
109
         COLUMNS='1'
110
         ;;
111
 
112
      t)
113
         MEDIA='Tabloid'
114
         PAGESIZE=${TABLOID_SIZE}
115
         ORIENT="--portrait ${LONG_EDGE_BINDING}"
116
         ;;
117
 
118
      v)
119
         verbose=true
120
         ;;
121
 
122
      \?)
123
         echo "Unrecognized option: ${opt}"
124
         echo
125
         Usage
126
         exit 1
127
         ;;
128
   esac
129
done
130
shift $(( ${OPTIND} - 1 ))
131
 
132
if [ $# -lt 1 ]
133
then
134
   echo "No files specified"
135
   echo
136
   Usage
137
   exit 1
138
fi
139
 
140
OPTS="${OPTS1} --columns=${COLUMNS} --media=${MEDIA} --font=${FONT} --tabsize=${TAB} ${ORIENT} --setpagedevice=PageSize:'${PAGESIZE}' ${PLEX}"
141
CMD="enscript -q ${PAGE_RANGE} ${OPTS} --printer ${PRT_OUTDEV}"
142
 
143
while [ -n "$1" ]
144
do
145
   #
146
   # Convert the path into a DOS format, but get the fully qualified filename
147
   #
148
 
149
   #FILE="'$(cygpath -w -a $1)'"
150
   FILE="'$1'"
151
 
152
   echo "Printing ${FILE} to ${PRT_OUTDEV} ..."
153
 
154
   if ${verbose}
155
   then
156
      echo "About to run ${CMD} ${FILE}"
157
   fi
158
 
159
   if ${execCmd}
160
   then
161
      eval "${CMD} ${FILE}"
162
   fi
163
   shift
164
done
165