Skip to content

Instantly share code, notes, and snippets.

@bruienne
Last active October 10, 2017 07:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bruienne/74ace1435cd5ce16b384 to your computer and use it in GitHub Desktop.
Save bruienne/74ace1435cd5ce16b384 to your computer and use it in GitHub Desktop.
Update unsigned/Sandbox-unaware PDEs (Print Dialog Extension) to work with Mavericks' heightened Sandboxing requirements.
#!/usr/bin/python
import os
import plistlib
# Modify basepath to point to another vendors' PDEs as needed.
basepath = '/Library/Printers/KONICAMINOLTA'
for root, dirs, files in os.walk(basepath):
for file in files:
if file.endswith('Info.plist'):
plist = plistlib.readPlist(os.path.join(root, file))
plist['PMSandboxCompatiblePDEs'] = True
print 'Modifying ' + os.path.join(root, file)
plistlib.writePlist(plist, os.path.join(root, file))
@bruienne
Copy link
Author

Modify 'basepath' for your needs.

@dayglojesus
Copy link

nice!

@dayglojesus
Copy link

In Ruby and including OS and directory checks

#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby

require 'find'
require 'osx/cocoa'

include OSX

MAC_OS_X_MAJOR_VERSION = `/usr/bin/sw_vers -productVersion`.chomp.to_f
KM_PDE_DIR = '/Library/Printers/KONICAMINOLTA'

if MAC_OS_X_MAJOR_VERSION >= 10.9
  if File.exists? KM_PDE_DIR
    Find.find(KM_PDE_DIR) do |path|
      if File.basename(path).eql? "Info.plist"
        plist = NSDictionary.dictionaryWithContentsOfFile path
        plist["PMSandboxCompatiblePDEs"] = true
        plist.writeToFile_atomically(path, true)
      end
    end
  end
else
  puts "Nothing to do here..."
end

exit 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment