mack icon indicating copy to clipboard operation
mack copied to clipboard

fix for providing an icon path in POSIX format

Open cwinters8 opened this issue 3 years ago • 1 comments

stumbled on an issue with supplying a local path to an icon file, where this error occurs:

exit status 1: 0:85: execution error: A resource wasn’t found. (-192) (display dialog "time's up!" with title "5s timer" with icon "./assets/clock_red.icns")

ultimately, the error occurs because applescript seems to expect files to be referenced by colon-delimited paths, otherwise known as a Hierarchical File System (HFS) path. you can tell applescript the path is POSIX format by adding the directive POSIX path before the file path is provided.

sorry for the very noisy diff - gofmt insisted on changing all the spaces to tabs. the specific change I am hoping to contribute here is found on line 84 here. if you'd like I can restore the original files and make the necessary changes with formatOnSave disabled as described here, because apparently there is currently no way to modify gofmt's behavior when used with the VS code extension.

the corresponding test is also updated, with similar space -> tab conversions by gofmt unfortunately.

I'm also wondering if this should be implemented in a more conditional manner, maybe with some special handling depending on if the dialog.Icon path is detected as POSIX or HFS format? I could add that logic as well if it would be helpful. the reason I did not implement that logic already is because I find it doubtful that most people will specify paths in HFS format, but I could definitely be wrong.

thanks for reviewing this!

cwinters8 avatar Oct 20 '22 19:10 cwinters8

this may address #11, if a dialog box is acceptable instead of a notification when a custom icon is needed

cwinters8 avatar Oct 20 '22 19:10 cwinters8