-
-
Save rderewianko/d842d07bd007f45f00de855f781f66a6 to your computer and use it in GitHub Desktop.
Give a folder an icon on a mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import Cocoa | |
import sys | |
Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(Cocoa.NSImage.alloc().initWithContentsOfFile_(sys.argv[1].decode('utf-8')), sys.argv[2].decode('utf-8'), 0) or sys.exit("Unable to set file icon") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @rderewianko I'm running macOS Monterey and have current python v.3.11 as well as legacy v.2.7.18 installed. Regardless if I invoke python2 or python3, I get:
import Cocoa ImportError: No module named Cocoa
Trying several hints on the web how to re-add Cocoa didn't help.
Do you have any idea how to make your script work again with current macOS? That would be awesome 👍