Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua
http://www.hammerspoon.org
MIT License
12.16k stars 587 forks source link

Spoon lifecycle behaviour tweaks #1480

Open z3t0 opened 7 years ago

z3t0 commented 7 years ago

There are a few things with the way spoons are installed that make it somewhat dangerous. Here are my recommendations

  1. There should be a dialog that asks if a spoon should be installed, that way you cannot accidentally install one.
  2. A copy of the spoon should be placed in the hammerspoon directory. The original should be left alone OR the user should be prompted if they want to remove it (similar to how installers ask to delete themselves)
  3. The spoon inside .hammerspoon/Spoons should not be a .spoon folder as it is too easy to accidentally open that file and it gets launched by hammerspoon. This has happened to me a few times and the spoon folder just gets mysteriously deleted from my system...

What do you think?

asmagill commented 7 years ago

I've done very little with the spoons, so I defer to others, but for what it's worth, here's my two cents:

I agree with points 1 and 2 whole heartedly and would add that if you're replacing an existing spoon (i.e. upgrading it to a newer version) you should be prompted to confirm this as well (I haven't used the spoon feature in a while, so if this already happens then disregard)

As to 3... while I agree that it shouldn't be deleted when you do this, the whole point of it being a bundle is that it is just that... a bundle that the finder treats as a single unit even though it's really just a folder with specific contents. In this case I would think that Hammerspoon should just silently ignore the action of double clicking on it. @cmsj?

z3t0 commented 7 years ago

I think a simple check here for whether the spoon is in the spoons directory would be perfect.

cmsj commented 7 years ago

I agree with point 1.

Point 2 I'm a little less sure about - my intention here was to copy the way that Safari installs extensions, which it does by moving the bundle. The behaviour I had in mind was someone downloading a .zip of a Spoon with a browser, which would put it in ~/Downloads/ and unzip it, they open the spoon and Hammerspoon ingests it and tidies up their Downloads folder.

For point 3 we can just special case the spoons path and ignore open requests for that.

cmsj commented 7 years ago
z3t0 commented 7 years ago

Point 2 I'm a little less sure about - my intention here was to copy the way that Safari installs extensions, which it does by moving the bundle. The behaviour I had in mind was someone downloading a .zip of a Spoon with a browser, which would put it in ~/Downloads/ and unzip it, they open the spoon and Hammerspoon ingests it and tidies up their Downloads folder.

Yeah that makes sense. It was just a quirk that I found annoying when developing a Spoon. For example I like navigating in the terminal and occasionally using open . to launch a finder. Now whenever I would accidentally do this while inside the project it would try to install the spoon but then delete it or something and then it would be nowhere ....

I think just to be on the safe side it would be nice to be prompted whether or not we want it to be deleted. However, with the changes you have suggested above it's not a big deal.