Cool, cool stuff.
I had so far not looked into Scripting for Bridge itself and Unix is beyond me …
Unfortunately I can’t seem to make it work for my purposes.
For use in a Photoshop-Script I suppose I would have to address Bridge via BridgeTalk and set the Default Printer, and this seems to work fine … unfortunately Photoshop does not seem to care about the Default Printer, but will print to the one last used from Photoshop itself.
I only got a s far as seeing if this was a possibility and this did work for me here. I set up a bunch of fake IP printers to test (half dozen).
I could then keep changing the index of the printerList array and each time this was the selected printer in the print dialog.
Printing added to the correct spoolers. What I think you may have to do is NOT have last used selected in system prefs.
This requires a little cleaning up as I cheated with the bridgetalk message for now. Don't know why filePath.remove(); is NOT working either will have to look at that too (could use shell rm but don't think I need to). Here is my rough test script…
#target photoshop
// Get current system default printer name
var defaultPrinter = osxGetDefaultPrinter();
// Get list of available system printers
var printerList = osxAvailablePrinters();
// Set system default to choice
osxSetDefaultPrinter(printerList[2]);
function osxGetDefaultPrinter() {
var shellString = "lpstat -d | awk '{print $4}' > ~/Desktop/OSX_Default_Printer.txt";
btMessaging('bridge', shellString);
var filePath = new File('~/Desktop/OSX_Default_Printer.txt');
var defaultPrinter;
filePath.open('r');
while (filePath.tell() < filePath.length) {
var defaultPrinter = filePath.readln();
}
filePath.close();
filePath.remove();
return defaultPrinter;
}
function osxAvailablePrinters() {
var shellString = "lpstat -a | awk '{print $1}' > ~/Desktop/OSX_Available_Printers.txt";
btMessaging('bridge', shellString);
var filePath = new File('~/Desktop/OSX_Available_Printers.txt');
var printerList = new Array();
filePath.open('r');
while (filePath.tell() < filePath.length) {
printerList.push(filePath.readln());
}
filePath.close();
filePath.remove();
return printerList;
}
function osxSetDefaultPrinter(printerName) {
var shellString = "lpoptions -d " + printerName;
btMessaging('bridge', shellString);
}
function btMessaging(targetApp, script) {
var bt = new BridgeTalk();
bt.target = targetApp;
bt.body = 'app.system(' + script.toSource() + ');';
//bt.onResult = function(inBT) {}
//bt.onError = function(inBT) {}
bt.send();
}
Get default printer could be recalled as a test as using bridge system commands don't return anything.