forked from MacsInSpace/iOS-AirPrint-for-Mac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Airprint.sh
143 lines (85 loc) · 3.52 KB
/
Airprint.sh
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
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
#PATH=/bin:/usr/bin:/sbin:/usr/sbin export PATH
# # # # # # # # # # # # # # # # # # # # # # # # # #
# Airprint.sh
# Original written by Macdeviant
# Forked by Kevin Duterne
# # # # # # # # # # # # # # # # # # # # # # # # # #
# Airprint enabler
#
# # # # # # # # # # # # # # # # # # # # # # # # # #
# - Enables Airprint for all printers that are shared via Macosx printer sharing
# # # # # # # # # # # # # # # # # # # # # # # # # #
## TO-DO
# Fix Script dns-sd
# Find URF string for different devices
# Add Install Launchd enabler
# Add Remove Install Launchd enabler
# Check cups.conf fo changes ( Or list printers to file and check changes)
##
## Notes
# NOT WORKING AT THIS TIME - WORK IN PROGRESS
# ------------------------------------------------------------------ VARIABLES ----------------------------------------------------------------------------- #
## URF
URF="W8,CP1,RS300-600,DM3,SRGB24"
## Get Computername
ComputerName=`scutil --get ComputerName`
# ------------------------------------------------------------------ VARIABLES END ----------------------------------------------------------------------------- #
# ------------------------------------------------------------------ FUNCTIONS --------------------------------------------------------------------------------- #
CHANGE_URF_STRING ()
{
echo "Add Function";
}
GET_PRINTERS ()
{
## Get all bonjour printers for printers belonging to $ComputerName and print to file "/tmp/printerlist.txt"
dns-sd -B _ipp._tcp local | colrm 1 73 > /tmp/printerlist.txt & sleep 1 & killall dns-sd
cat /tmp/printerlist.txt | grep -v 'Instance Name' | sort | uniq | grep ${ComputerName} > /tmp/printerlist.txt
## List printers
printers=`cat /tmp/printerlist.txt`;
}
TEST_PRINTERS ()
{
## For each printer listed, Get the dns-sd full details and print them to file as titled by the printer name.
## Adds the urf format and "transparent=T binary=T" settings which I believe are needed
for i in $printers; do
txt=`echo "$i" | sed 's/\ /+/g'`
echo $i;
echo $txt;
dns-sd -L "$i" _ipp._tcp local > /tmp/"$i" & sleep 1 & killall dns-sd
Options=`cat /tmp/"$i" | grep 'product=' | tr -d \'\\\\\(\) | sed "s@pwg-raster@urf URF=$URF@g" | sed "s/$/ transparent=T binary=T/" | sed 's/note.*priority/note= priority/g' | uniq`
echo $Options;
dns-sd -R "$i""2" _ipp._tcp,_universal . 631 $Options & sleep 1 &
done
}
CHECK_PRINTERS ()
{
#Check if printer is working
echo "Check if Printer is working on IOS device"
}
# ------------------------------------------------------------------ FUNCTIONS END ------------------------------------------------------------------------------------ #
# ------------------------------------------------------------------ CALL FUNCTIONS ----------------------------------------------------------------------------------- #
GET_PRINTERS;
TEST_PRINTERS;
CHECK_PRINTERS;
# ------------------------------------------------------------------ CALL FUNCTIONS END ------------------------------------------------------------------------------- #
exit 0
#SAVEIFS=$IFS
#IFS=$(echo -en "\n\b")
#Procedure to
#for i in $printers; do
#IFS=$(echo -en "\n\b")
#Options=`cat /tmp/"$i"`
#IFS=$SAVEIFS
#dns-sd -R "$i""2" _ipp._tcp,_universal . 631 $Options & sleep 1 &
#done
#alias TheCommand="dns-sd -R "\"\$i"\" _ipp._tcp,_universal . 631 "$Options" & unalias TheCommand"
#for i in $printers; do
#Options=`cat "$i"`
#TheCommand
#done
#IFS=$SAVEIFS
#for i in $printers; do
#Options=`cat "$i"`
#dns-sd -R "$i" _ipp._tcp,_universal . 631 $Options & sleep 0 &
#done