Skip to content

Instantly share code, notes, and snippets.

@bedartha
Last active June 16, 2019 05:16
Show Gist options
  • Select an option

  • Save bedartha/5845444 to your computer and use it in GitHub Desktop.

Select an option

Save bedartha/5845444 to your computer and use it in GitHub Desktop.
Fetch running apps and their icons on OS X using PyObjC
from AppKit import NSWorkspace
sharedWorkspace = NSWorkspace.sharedWorkspace()
launchedApps = sharedWorkspace.launchedApplications()
for liveApp in launchedApps:
appName = str(liveApp.allValues()[-1]
appPath = str(liveApp.allValues()[0])
appIcon = sharedWorkspace.iconForFile_(appPath)
icoPath = './' + appName + '.png'
appIcon.TIFFRepresentation().writeToFile_atomically_(icoPath, False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment