Jump to content

Can someone explain the three kinds of icon options for script filter JSON?


Recommended Posts

Posted (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)

image.thumb.png.134081389b75a1490952736c2cb5803e.png

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 by Mr Pennyworth
Link to comment
Posted (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 by deanishe
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...