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.