-
Notifications
You must be signed in to change notification settings - Fork 4
/
modify-ppd
executable file
·130 lines (109 loc) · 2.15 KB
/
modify-ppd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
PROGNAME="$0"
usage() {
cat <<EOF
NAME
`basename $PROGNAME` - modify the PPD for doing marker (toner) levels
SYNOPSIS
`basename $PROGNAME` [options]
DESCRIPTION
Modify the PPD for doing marker (toner) levels. It reads from stdin
and writes to stdout.
OPTIONS
-D lvl Debug level
EXAMPLE
$ modify-ppd < PPD/KONICA_MINOLTA-magicolor_2530_DL.ppd |
gzip > /usr/share/cups/model/KONICA_MINOLTA-magicolor_2530_DL.ppd.gz
EOF
exit 1
}
#
# Report an error and exit
#
error() {
echo "`basename $PROGNAME`: $1" >&2
exit 1
}
debug() {
if [ $DEBUG -ge $1 ]; then
echo "`basename $PROGNAME`: $2" >&2
fi
}
#
# Process the options
#
DEBUG=0
while getopts "D:h?" opt
do
case $opt in
D) DEBUG="$OPTARG";;
h|\?) usage;;
esac
done
shift `expr $OPTIND - 1`
#
# Main Program
#
#
# Portable version of 'which'
#
pathfind() {
if [ "$1" = -p ]; then
optp=1
shift
else
optp=0
fi
OLDIFS="$IFS"
IFS=:
for p in $PATH; do
if [ -x "$p/$*" ]; then
if [ $optp = 1 ]; then
echo "$p/$*"
fi
IFS="$OLDIFS"
return 0
fi
done
IFS="$OLDIFS"
return 1
}
#
# Modify select PPD files
#
if pathfind cups-config; then
cupsdev=1
else
cupsdev=0
fi
awk '
BEGIN {
negate = 1
}
{
print
}
/"\(C110\)"/ { do_cmd = "foo2lava-pjl" }
/"\(mc1600W\)"/ { do_cmd = "foo2lava-pjl" }
/"\(mc1680MF\)"/ { do_cmd = "foo2lava-pjl" }
/"\(mc1690MF\)"/ { do_cmd = "foo2lava-pjl" }
/"\(magicolor 2490 MF\)"/ { do_cmd = "foo2lava-pjl" }
/"\(mc2530DL\)"/ { do_cmd = "foo2lava-pjl"; negate = 0 }
/"\(magicolor 4690MF\)"/ { do_cmd = "foo2lava-pjl" }
/^\*cupsFilter:.*pdf/ {
if (cupsdev && do_cmd)
{
print "*cupsFilter:\t\"application/vnd.cups-command 200 command2" \
do_cmd "\""
print "*% Specify the list of commands we support"
print "*cupsCommands:\t\"PrintSelfTestPage ReportLevels\""
print "*% SNMP marker levels are WRONG..."
print "*cupsSNMPSupplies:\tFalse"
# When cups gets updated for USB bidirectional (v1.5???) ...
# print "*cupsBIDI:\tTrue"
print "*% Negate marker levels..."
printf "*foo2zjsNegateMarkerLevels:\t%s\n",
negate ? "True" : "False"
}
}
' cupsdev=$cupsdev