├── Airprint.sh ├── README.md └── notesandtests.txt /Airprint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #core shell script/service to mirror Mac printers to Airprint 4 | 5 | 6 | ## Get Computername 7 | ComputerName=`scutil --get ComputerName` 8 | 9 | ## Get all bonjour printers for printers belonging to $ComputerName and print to file "/tmp/printerlist.txt" 10 | 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 11 | 12 | SAVEIFS=$IFS 13 | IFS=$(echo -en "\n\b") 14 | 15 | ## List printers 16 | printers=`cat /tmp/printerlist.txt` 17 | 18 | ## For each printer listed, Get the dns-sd full details and print them to file as titled by the printer name. 19 | ## Adds the urf format and "transparent=T binary=T" settings which I believe are needed 20 | 21 | for i in $printers; do 22 | 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 & 23 | killall dns-sd 24 | done 25 | 26 | 27 | 28 | 29 | 30 | for i in $printers; do 31 | Options=`cat /tmp/"$i"` 32 | 33 | dns-sd -R "$i" _ipp._tcp,_universal . 631 $Options & sleep 0 & 34 | 35 | done 36 | 37 | 38 | 39 | IFS=$SAVEIFS 40 | 41 | 42 | 43 | 44 | 45 | 46 | #alias TheCommand="dns-sd -R "\"\$i"\" _ipp._tcp,_universal . 631 "$Options" & unalias TheCommand" 47 | 48 | #for i in $printers; do 49 | #Options=`cat "$i"` 50 | 51 | #TheCommand 52 | 53 | #done 54 | 55 | 56 | 57 | #IFS=$SAVEIFS 58 | 59 | 60 | 61 | #for i in $printers; do 62 | #Options=`cat "$i"` 63 | 64 | #dns-sd -R "$i" _ipp._tcp,_universal . 631 $Options & sleep 0 & 65 | 66 | #done 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | iOS-AirPrint-for-Mac 2 | ==================== 3 | 4 | enable iOS Airprint Sharing on Mac OS 5 | 6 | A proof of concept that works mostly but is no longer developed. 7 | -------------------------------------------------------------------------------- /notesandtests.txt: -------------------------------------------------------------------------------- 1 | 2 | ComputerName=`scutil --get ComputerName` 3 | dns-sd -B _ipp._tcp local | colrm 1 73 | grep -v 'Instance Name' | sort | uniq | grep ${ComputerName} > ST00447printerlist.txt & sleep 1 & killall dns-sd 4 | 5 | SAVEIFS=$IFS 6 | IFS=$(echo -en "\n\b") 7 | 8 | printers=`cat ST00447printerlist.txt` 9 | 10 | for i in $printers; do 11 | dns-sd -L "$i" _ipp._tcp local | grep 'product=' | tr -d \'\\\\\(\) | 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 & 12 | killall dns-sd 13 | done 14 | 15 | for i in $printers; do 16 | Options=`cat /tmp/"$i"` 17 | TheCommand=`dns-sd -R "$i" _ipp._tcp,_universal . 631"$Options" | tr -d \'\\\\\(\)\" >> output.log & sleep 1` 18 | 19 | $TheCommand 20 | 21 | done 22 | 23 | 24 | 25 | IFS=$SAVEIFS 26 | 27 | 28 | 29 | killall dns-sd 30 | 31 | Helpful links 32 | http://www.finnie.org/2010/11/13/airprint-and-linux/ 33 | https://www.sit.auckland.ac.nz/Printing/Sharing_a_printer_to_iOS_from_MacOS 34 | http://hints.macworld.com/article.php?story=20101027080807322 35 | http://blog.mornati.net/linux-as-airprint-server/ 36 | http://the.taoofmac.com/space/blog/2012/12/15/1830 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | sed -i 's/note=.*priority=/note= priority=/g' 45 | 46 | Options=`cat "/Users/****/Canon MP270 series @ MacbookPro"` 47 | dns-sd -R "Canon MP270 series @ MacbookPro" _ipp._tcp,_universal . 631${Options} 48 | 49 | 50 | 51 | dns-sd -R "Canon MP270 series @ MacbookPro" _ipp._tcp,_universal . 631 txtvers=1 qtotal=1 rp=printers/Canon_MP270_series ty=Unknown adminurl=https://MacbookPro.local.:631/printers/Canon_MP270_series note= priority=0 product=Canon MP270 series pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/urf URF=W8,SRGB24,CP255,RS300 UUID=2c7087de-2ab6-3770-7ebd-4c4ba18ceb7b TLS=1.2 Color=T Scan=T printer-state=3 printer-type=0x480900E transparent=T binary=T >> output.log & sleep 0 & 52 | 53 | 54 | 55 | 56 | 57 | 58 | dns-sd -R "Canon MP270 series @ MacbookPro" _ipp._tcp,_universal . 631 txtvers=1 qtotal=1 rp=printers/Canon_MP270_series ty=Unknown adminurl=https://MacbookPro.local.:631/printers/Canon_MP270_series note=Carolines AirPort TimeCapsule priority=0 product=Canon MP270 series pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/urf URF=W8,SRGB24,CP255,RS300 UUID=2c7087de-2ab6-3770-7ebd-4c4ba18ceb7b TLS=1.2 Color=T Scan=T printer-state=3 printer-type=0x480900E transparent=T binary=T 59 | 60 | 61 | 62 | dns-sd -R "Canon MP270 series @ MacbookPro" _ipp._tcp,_universal . 631 txtvers=1 qtotal=1 rp=printers/Canon_MP270_series ty=Unknown adminurl=https://MacbookPro.local.:631/printers/Canon_MP270_series note= priority=0 product=Canon MP270 series pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/urf URF=W8,SRGB24,CP255,RS300 UUID=2c7087de-2ab6-3770-7ebd-4c4ba18ceb7b TLS=1.2 Color=T Scan=T printer-state=3 printer-type=0x480900E transparent=T binary=T 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | dns-sd -B _ipp._tcp local | colrm 1 73 | grep -v 'Instance Name' | sort | uniq | sed '/@/d' | sed "s/$/ @ ${ComputerName}/" > ST00447printerlist.txt & sleep 1 & killall dns-sd 73 | 74 | Working 75 | dns-sd -R "Canon MP270 series @ MacbookPro" _ipp._tcp,_universal . 631 txtvers=1 qtotal=1 rp=printers/Canon_MP270_series ty=Unknown adminurl=https://MacbookPro.local.:631/printers/Canon_MP270_series note= priority=0 product=\(Canon\ MP270\ series\) pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/urf URF=W8,SRGB24,CP255,RS300 UUID=2c7087de-2ab6-3770-7ebd-4c4ba18ceb7b TLS=1.2 Color=T Scan=T printer-state=3 printer-type=0x480900E transparent=T binary=T 76 | 77 | 78 | dns-sd -R "Canon MP270 series @ MacbookPro" _ipp._tcp,_universal . 631 txtvers=1 qtotal=1 rp=printers/Canon_MP270_series ty=Unknown adminurl=https://MacbookPro.local.:631/printers/Canon_MP270_series note= priority=0 product=\(Canon\ MP270\ series\) transparent=T binary=T Fax=F Color=T pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/urf URF=W8,SRGB24,CP255,RS300 79 | 80 | 81 | 82 | 83 | 84 | dns-sd -L "$i" _ipp._tcp local | grep 'product=' | sed "s@\\@@g" | sed "s/'/ /g" | sed "s@pwg-raster@urf URF=W8,SRGB24,CP255,RS300@g " > "$i".txt & sleep 1 85 | 86 | sed "s@\\\\@@g" | sed "s@\(@\\"\(@g" | sed "s@\)@\\"\)@g" | 87 | sudo cat /private/etc/cups/printers.conf | grep "Info " | colrm 1 5 | sort | uniq | sed '/@/d' > ST00447printerlist.txt 88 | 89 | 90 | Options=`cat "/Users/craighair/Canon MP270 series @ MacbookPro"` 91 | dns-sd -R "Canon MP270 series @ MacbookPro" _ipp._tcp,_universal . 631 $Options 92 | 93 | working 94 | dns-sd -R "Canon MP270 series @ MacbookPro" _ipp._tcp,_universal . 631 \ 95 | txtvers=1 qtotal=1 rp=printers/Canon_MP270_series \ 96 | ty=Unknown adminurl="https://MacbookPro.local.:631/printers/Canon_MP270_series" note= \ 97 | priority=0 product="(Canon MP270 series)" transparent=T binary=T \ 98 | Fax=F Color=T \ 99 | pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/urf \ 100 | URF=W8,SRGB24,CP255,RS300 101 | 102 | 103 | killall dns-sd 104 | 105 | orig 106 | dns-sd -R "The Printer" _ipp._tcp,_universal . 631 \ 107 | txtvers=1 qtotal=1 rp=printers/Brother_DCP_J125 \ 108 | ty="Brother DCP-J125 CUPS" adminurl= note=Downstairs \ 109 | priority=0 product="(DCP-J125)" transparent=T binary=T \ 110 | Fax=F Color=T \ 111 | pdl=application/octet-stream,application/pdf,application/postscript,image/jpeg,image/png,image/urf \ 112 | URF=W8,SRGB24,CP255,RS300 UUID=2c7087de-2ab6-3770-7ebd-4c4ba18ceb7b TLS=1.2 Color=T Scan=T printer-state=3 printer-type=0x480900E 113 | --------------------------------------------------------------------------------