untoldwind / alfred2-layout

Alfred 2 Layout workflow
http://untoldwind.github.io/projects/alfred2-layout.html
199 stars 16 forks source link

Wrong path for layouts.yaml #20

Closed omriza closed 6 years ago

omriza commented 6 years ago

I was trying to add some new layouts by editing layouts.yaml in the workflow path. When testing the new layouts I saw that this file is never being read by the layout_select.pl script. Only then I figured out that there's a keyword for that purpose (lay_config), but yet, when using Alfred3, this keyword's logic will create the files in a wrong path (which will still work, but won't be as nice).

Absolute paths for files, like in this line from lay_config bash script: if [ ! -d ~/Library/Application\ Support/Alfred\ 2/Workflow\ Data/de.leanovate.alfred.layout ]; then Makes the target files being created in wrong paths for Alfred3 users. In addition, layout_select.pl uses this same absolute path to load custom layouts.

This issue can be easily fixed by using relative paths, Alfred runs embedded scripts from the main workflow path so ./Data/de.leanovate.alfred.layout/layouts.yaml will suite the case.

Thanks for this very useful workflow!

untoldwind commented 6 years ago

Unluckily I use my Mac very rarely now. I'll try to reproduce/fix this on the weekend.

omriza commented 6 years ago

Easiest way to reproduce is to run the lay_config keyword cmd from an Alfred3 instance. If not already exists, this will create:

~/Library/Application\ Support/Alfred\ 2/Workflow\ Data/de.leanovate.alfred.layout
~/Library/Application\ Support/Alfred\ 2/Workflow\ Data/de.leanovate.alfred.layout/layouts.yaml

I'm not sure how Alfred2 handles relative paths, just a note for testing, we don't want to break Alfred2 backwards compatibility.

Let me know if you don't get to fix it, I can do it and open a PR.

untoldwind commented 6 years ago

A PR would be cool as I'm not sure what version of Alfred I still have.

untoldwind commented 6 years ago

Made some minor changes, but otherwise lgtm. Uploaded the new version to packal.

Just reopen the issue if it's not working for reasons.

omriza commented 6 years ago

I'm afraid this will cause Alfred 2 to always use the path defined here.

I've opened PR#22 with a proposed change to this logic.

It will be best if you could add a documentation for this feature in the wiki as the current Hacking section of README.md is outdated.