-
Notifications
You must be signed in to change notification settings - Fork 8
/
Airprint.sh
69 lines (31 loc) · 1.37 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
#!/bin/bash
#core shell script/service to mirror Mac printers to Airprint
## Get Computername
ComputerName=`scutil --get ComputerName`
## 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 | grep -v 'Instance Name' | sort | uniq | grep ${ComputerName} > /tmp/printerlist.txt & sleep 1 & killall dns-sd
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
## List printers
printers=`cat /tmp/printerlist.txt`
## 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
dns-sd -L "$i" _ipp._tcp local | grep 'product=' | sed 's/\\//g' | sed "s@pwg-raster@urf URF=W8,SRGB24,CP255,RS300@g" | sed "s/$/ transparent=T binary=T/" | sed 's/note.*priority/note= priority/g' > /tmp/"$i" & sleep 0 &
killall dns-sd
done
for i in $printers; do
Options=`cat /tmp/"$i"`
dns-sd -R "$i" _ipp._tcp,_universal . 631 $Options & sleep 0 &
done
IFS=$SAVEIFS
#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