Mr Pennyworth Posted May 26, 2021 Share Posted May 26, 2021 (edited) Following is from the JSON spec for script filter output: Quote "icon": { "type": "fileicon", "path": "~/Desktop" } By omitting the "type", Alfred will load the file path itself, for example a png. By using "type": "fileicon", Alfred will get the icon for the specified path. Finally, by using "type": "filetype", you can get the icon of a specific file, for example "path": "public.png" I'm having trouble understanding the difference between "filetype" and "fileicon" in my tests so far, it seems like "filetype" always gives a generic blank file icon (even for folders). Take a look at this screenshot. (Download the corresponding workflow) In case you don't feel like downloading the workflow, but just want to take a look at the script filter JSON: file1="icon.png" file2="~/Desktop" file3="./" cat << EOF {"items":[ {"title": "$file1", "subtitle": "no type", "icon": {"path": "$file1"}}, {"title": "$file1", "subtitle": "type: fileicon", "icon": {"type": "fileicon", "path": "$file1"}}, {"title": "$file1", "subtitle": "type: filetype", "icon": {"type": "filetype", "path": "$file1"}}, {"title": "$file2", "subtitle": "no type", "icon": {"path": "$file2"}}, {"title": "$file2", "subtitle": "type: fileicon", "icon": {"type": "fileicon", "path": "$file2"}}, {"title": "$file2", "subtitle": "type: filetype", "icon": {"type": "filetype", "path": "$file2"}}, {"title": "$file3", "subtitle": "no type", "icon": {"path": "$file3"}}, {"title": "$file3", "subtitle": "type: fileicon", "icon": {"type": "fileicon", "path": "$file3"}}, {"title": "$file3", "subtitle": "type: filetype", "icon": {"type": "filetype", "path": "$file3"}}, ]} EOF Edited May 26, 2021 by Mr Pennyworth Link to comment
deanishe Posted May 26, 2021 Share Posted May 26, 2021 (edited) 1 hour ago, Mr Pennyworth said: I'm having trouble understanding the difference between "filetype" and "fileicon" fileicon means “use the icon of this file”, e.g. use path = "/Applications/Safari.app" to show Safari’s icon. filetype is for UTIs, not paths (which is why you’re not seeing any icon). Use path = "public.folder" to display a folder icon or com.adobe.pdf to display a PDF icon. You might find the docs for my libraries useful. I write a lot of this stuff down in there, so I don't forget. Edited May 26, 2021 by deanishe Mr Pennyworth 1 Link to comment
Mr Pennyworth Posted May 26, 2021 Author Share Posted May 26, 2021 @deanishe 🙏🏼 thanks soooo much!! 😇 @Andrew what say for borrowing from deanishe's documentation to update the JSON spec doc? Link to comment
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