cleobis Posted July 4, 2021 Posted July 4, 2021 There is an old plugin (https://github.com/cleobis/alfred-cal) that I am attempting to rehabilitate. It used the clever trick of printing the perfect number of spaces in the results to create the illusion of a multi-column grid layout. To get the spacing right you need the font and font size for the active theme. The plugin parses the preference plist for older versions of Alfred to obtain this information. This no longer works in the current version of Alfred. I see that the theme id is available from the alfred_theme environment variable (https://www.alfredapp.com/help/workflows/script-environment-variables/). If the theme is "theme.custom.<id>", I then parse the corresponding file in $alfred_preferences/themes/theme.custom.<id>/theme.json. If the theme is "theme.bundled.*", I then need to parse the corresponding file in "Alfred 4.app/Contents/Frameworks/Alfred Framework.framework/Versions/Resources/*.alfredappearence". Two questions: i) Is there a portable way to find the location of Alfred 4.app? The best option I found is to call URLForApplicationWithBundleIdentifier() (https://developer.apple.com/documentation/appkit/nsworkspace/1534053-urlforapplicationwithbundleident) via the Python Objective-C bridge. ii) Is there a method to convert between between e.g. "theme.bundles.default" and the filename e.g. "Alfred 4.app/Contents/Frameworks/Alfred Framework.framework/Versions/Resources/Alfred.alfredappearence"? In the absence of information, it looks straightforward to reverse engineer the current options.
deanishe Posted July 4, 2021 Posted July 4, 2021 1 hour ago, cleobis said: Is there a portable way to find the location of Alfred 4.app? The way you’ve found is probably the best way. You could also use the shell command lsappinfo info -app com.runningwithcrayons.Alfred | grep 'bundle path' | cut -d'"' -f2 That only works for running applications, but that shouldn't be a problem when looking for info about Alfred from a workflow. 1 hour ago, cleobis said: Is there a method to convert between between e.g. "theme.bundles.default" and the filename e.g. "Alfred 4.app/Contents/Frameworks/Alfred Framework.framework/Versions/Resources/Alfred.alfredappearence"? No. That's an arbitrary path that Andrew has chosen. Just joining the paths should work fine, though.
vitor Posted July 5, 2021 Posted July 5, 2021 For completeness, one more way to find an app’s path from the bundle identifier: mdfind kMDItemCFBundleIdentifier = com.runningwithcrayons.Alfred. deanishe 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now