I was just trying to write my custom Swift Accessibility Application, but hopefully Hammerspoon will suffice. Then I might get rid of Spectacle and SmartScroll, which are nice, but I do not need all these features.
Hammerspoon is a fork from https://github.com/sdegutis/mjolnir. Mjolnir is a hammer of Thor. So it's kinda hammer but not the same hammer and it's kinda fork, yet it's not meant to be merged back - so not really a fork. Hence the name.
As we added feature after feature to Mjolnir, and it grew to a monolithic collection of barely-related modules (APIs), I realized that it didn't make a lot of sense for users to keep upgrading to "newer" versions of Mjolnir, when in reality it was just the modules bundled with Mjolnir that were new or changed, and Mjolnir itself wasn't changed at all.
So I made the decision to decentralize the APIs. Instead of being bundled into Mjolnir itself, users would be able to download Mjolnir and then download or upgrade modules independently of Mjolnir.
This was pretty unpopular, because it meant Mjolnir was no longer "batteries included", so Hammerspoon was forked by the portion of the community that preferred that batteries included approach. Honestly, I don't even know how much of the community (if any) continued to use Mjolnir.
Huh, interesting. It sounds like you and the Hammerspoon devs are on good terms, so it's not clear why this couldn't have been resolved in the Mjolnir project. Does this have anything to do with <http://sdegutis.github.io/2016-05-30/why-i-dont-side-program...? Did you actually prefer to have other people take over the project?
Nope, that has nothing to do with what I said in that blog post. In fact, the point in that blog post was that I enjoy making things like Mjolnir, and specifically prefer it over building apps like, well, anything you'd see on the front page of the Mac App Store any day of the week.
They forked it because of a difference of opinion: I believe that separation of the core app and the modules into separate projects is ultimately better, and they don't.
When they're separate projects, there's a lot of potential for really interesting tools to be built around them, between them, or bridging them together.
Imagine having a GUI app that manages third party modules for you, installing and loading them at a single click. Or a plugin that centralizes plugin settings into a unified single GUI window. These are the kinds of things that this separation was meant to allow and encourage.
But when it's a batteries-included app, every single aspect of it needs to be built into the app. It becomes monolithic. Every feature anyone could ever want needs to be bundled into it, and even though this is more convenient at first, it ends up bloated. It also doesn't allow for any competition between features in the same domain.
The authors behind Hammerspoon prefer the batteries-included approach. They're not wrong, it's not a matter of right or wrong. It's just a difference of opinion. People who want that approach will prefer Hammerspoon. People who want to build tools around their existing tools will probably prefer Mjolnir.
Sounds like the distro problem. Yes, a lean, mean, linux machine is great, but when you have to hunt around for all the tools you want, it becomes a pain to manage. Far nicer to have a curated set of tools that most people can agree upon.
In this case, mjolnir, the lean mean core, then the various subprojects, and finally the "distro", containing a curated set of popular modules that people can download as a turnkey system. Then, if you want your own custom setup, minus the bloat, you can set up your own distro. If you just want to use the damn thing and don't care about how the sausage is made, use the "recommended" distro.
Have a centralized repository containing pointers to all available modules. Module creators can publish to this repository. Cocoapods does this rather nicely, and uses github for the centralized repo.
Then have a tool inside mjolnir that allows administration of the repo (request adding your module, publish a new version of your module, etc).
Then have a "distro" format that lists what modules are included in your distro. This is doubly cool because if you have to install another machine, you just call upon your distro, it installs everything and you're good to go. It also makes upgrading to the latest and greatest modules a breeze.
I guarantee that 90% of your users will just go with the "recommended" distro, but the developers will love you for making it a lot easier to contribute. It's all about lowering friction, for users, power users, and devs.
Thanks for the prompt reply! I was looking for more of a you can do things in Lua and get to Windows functions. AutoHotKey looks cool, but it appears to be it's own little language.
I'm pretty fluent in Lua, so being able to leverage ability like Hammerspoon does would be great.
AHK is a terribly designed language, but holy hell, you can do some nifty stuff with it. For instance, I like to download music from YouTube and SoundCloud using youtube-dl but I disliked having to open up and manually copy and pasting the URL, etc. I found an AHK script that gets the URL name of the current active Firefox window, edited it a little so that it pipes that URL into a batch file, and now if I find a song I like, all I have to do is hit a hotkey chord and after about 30 seconds, it's in my Music folder. It is a total hack - the kind of thing AHK was made for - but somehow it works!
I have written a custom i3 like window manager that I use for tiling. I use it to catch keyboard shortcuts and open new windows/lock screen/movement commands/etc.
Hammerspoon is awesome, I've been using it for quite some time for just few basic tasks (like move a window from one monitor to another), but those have become irreplaceable part of my desktop experience.
He man. Looks cool.. Maybe I'll extend it to just filter out any applications that have no window in the current space. Cleans up the cmd-tab list a lot
Sure, try it. It might work better than my version. I do have some other ideas for this problem (usually, i just want to fast switch between terminal and browser) but I'd like to see what other people come up with.
Hammerspoon is amazing, and even more impressively, it's amazingly well maintained and its API is incredibly well thought out by its really talented development team. It really is a must-have for anyone who wants ultimate programmatic control over OS X.
Check out the really gentle follow-along tutorial:
I think we made some terrible API decisions, but we'll fix them up eventually!
(Also for those following along at home, sdegutis is the author of a long line of OS X automation tooling, up to and including Mjolnir, which we forked to make Hammerspoon. He is awesome)
That's right. Sdegutis built Zephyros (Ruby OSX automation, also other Lang support), then Phoenix (JavaScript OSX Automation), then Hydra (Lua based) which became Mjolnir, which is forked to Hammerspoon.
In the original post, I left out that I also have a usb LED sign [1] that I also have programmed, so people know when they can and cannot interrupt me. Again controlled with hammerspoon and my yubikey.
Fantastic idea! One day I hope this will be replaced by me walking away (with my phone) for more than X meters. Meanwhile, this seems like a great solution. What else do you use the ubikey for?
This reminds me of the pull request I did for Hammerspoon to allow your scripts to watch more screen lock and user switching events. My goal was to delete keys from the ssh-agent when the screen locks or the computer suspends.
I use it primarily as a windows manager and an easy way to start and stop Spotify/iTunes.
This (https://github.com/Linell/hammerspoon-config) is my configuration, which is about as basic as it gets. The documentation has a billion other, cooler things that can be done.
Your computer should be waiting for you, not you waiting for your computer. Any single job you're doing more than once, look at how you can do it easier.
Look at emmet if you do anything involving html.
Maybe setup a process that watches a folder and builds/compiles anything placed in there.
If you need to do a job 10 times that takes 5 hours to do each time and you can automate that job in 30 hours so each job now only takes 1 hour each then you've saved 10 hours of time.
At my work I've made an enewsletter editor app (turned 2 week job down to 3 days job) and a language file editor for the content we output (turned 1 week job into 1 day job)
All that extra time gives you more breathing room between projects, more polish time for those projects or more time to learn new things.
After jumping through some hoops, I now have caps lock usable as a shortcut button. Here's some things I do with it:
CAPS + 1 = Bring up Bash
CAPS + 2 = Bring up IntelliJ
CAPS + 3 = Bring up Chrome
CAPS + 4 = Bring up Geany
CAPS + 5 = Bring up SourceTree
CAPS + F1 = Chat software
CAPS + F2 = Email
CAPS + F = Full screen the current app (But not really fullscreen - it's like option + green button, except width too)
CAPS + W = Cycle the wifi
CAPS + V = Paste text from the clipboard by typing it in, accounting for tab indentations. This is useful for copying things from Outlook into Confluence. Stupid Confluence.
I've written a script for this to snap windows just like windows (consider it a free cinch & sizeup replacement).
- Drag to the left or right to cover that half of the screen.
- Drag to the top for maximise
- Drag to a corner for corner snap
- Control + Option + Arrow to snap to left or right of screen, maximise or center
- Control + Option + Command + Arrow to snap to corner of screen
Mjolnir is decentralized and modularized, where everything is a plugin. Hammerspoon is batteries-included, where everything is built in. Neither is better or worse, they're just different approaches.
Something I don't see on the front page, the first few screens of the Getting Started page, or the landing page of the API docs is the version of Lua being used.
Edit: After binding a hotkey to hs.alert.show(_VERSION), it seems to be Lua 5.3.
Edit 2: Oh Hammerspoon has an interactive console. Typing _VERSION in there would have been slightly simpler.
When I first started using a Mac a year ago I found the UI very awkward to use but then I found this little app. Hammerspoon makes osx great again! Even just moving windows around or maximizing (without going fullscreen) is so useful.
I almost never use Dock, Spotlight or Finder now. It's great!
That doesn't work on OS X 10.11. Just tried it - Nothing happens. You need a tool like Spectacle/Magnet (or potentially Hamerspoon, haven't tried it yet) - I don't know of any way to maximize a screen using basic OS X 10.11 interface, which is bizarre if you think about it.
Did you try shift or alt, or combinations of those? I'm pretty sure it's been hidden in OSX for a while, but I think the shortcuts were changed at some point.
It works just fine on OS X 10.11 [1]. Holding down 'option' while you hover over the green traffic light icon changes the glyph to a '+'. Clicking it maximises the window.
It really doesn't. I just did so in Safari. Held the Option key, hovered over the green traffic light, and it first reduced the size of the screen. I clicked on it again, and it filled the screen vertically, but not horizontally. Still need to use Magnet/Spectacle to maximize my window.
I think the problem really is Apple's use of the term "maximise" doesn't mean what it does on other platforms, and really it's a misnomer entirely. "Optimise" would be a better adjective, and its behaviour differs slightly depending on the app. For example, in Safari it'll resize the browser window to what it thinks is best for the content you're viewing.
Thankfully, tools like you've discovered address this behaviour and add a lot of other useful window management features anyway.
The weird thing is the behavior doesn't seem to be predictable. I just maximized my screen with Magnet (cause window to stretch out both horizontally and vertically), then I option-clicked on the Green Streetlight - Nothing happened. Then I made the window a bit narrower. Clicked again. Nothing happened. Then I made it a bit shorter. Clicked Again - Window stretched up to top, but didn't change width. Made it narrower. Clicked again. Window returned to previous width. Clicked again, this time returned to the same narrower size as one step previous.
It seems like the Option+Click on the streetlight is kind of like a toggle of the last two previous sizes, but not always - sometimes it stretches to the top, sometimes it doesn't do anything.
I've been a dedicated OS X user since 10.3 - and, despite spending 15-20 minutes at a stretch every year or so (such as tonight) - I've never really understood what the green button is supposed to do. I kind of find it amazing that such a horribly inconsistent user interface control has persisted for 15+ years.
But yet - Magnet (much like Spectacle before it) does exactly what I want. Ctrl+Option+Enter = Maximize window (which is exactly what I bet 99% of people want the Green Button to do)
For example, you could make text editing (in apps that use the Cocoa text editor libraries and input fields etc..., which are most of them) act like Vim or Emacs, or Windows, or whatever you want.
Has anyone tried to implement a fully blown list of tests (TDS) for a production Mac app using this ? ( or mjolnir ). In one of my previous assignments, we had to build automation for our Desktop Mac App, We tried AppleScripts and a couple of other open source libraries , None of them worked out we had to settle for manual testing !
One thing I love about Hammerspoon is the flexibility and power some of the modules like drawing and event spoofing give you. It allows really neat things like the tabs and hints modules (which I wrote) and lately I hacked together a module that lets me scroll pages hands-free using mouth noises (see https://github.com/trishume/thume.popclick if you want to test it before I try and PR it to Hammerspoon).
It's useful both for general window management as well as system hackery. It's the closest OS X users can get to the power of Linux.
> It has a very low false negative rate, but often has false positives.
Seems like it would get triggered constantly around noises like A/C, or wind, or the inevitable coworker who quietly hisses behind you while you've got your headphones on.
It's only succeptible to some very specific false postives. But yes it is annoying (my roommate was having fun scrolling my computer from a distance today).
The answer is that all the false positives I encounter are human-triggered so if you are alone and not doing anything else except reading, they aren't much of an issue.
You can also buy super directional headsets that don't pick up anything else, even other people making the noises standing next to you. I have one and it works great, just not as convenient as the tiny mike on my earbuds.
Nice. I recently gotten into playing Dolphin emulator, but it doesn't disable the screensaver and mine is set to turn on after one minute. I was looking for a way to listen for a certain app to open and set the the screensaver to never turn on and reset it to one minute when the app is closed. It seemed like there was no real way to do it aside from polling if the app is still open. I'll see what this can do
Looks great. I'll have to download it and have a go.
Another seemingly great product for Apple not by Apple. I just downloaded the app Continous to my iPad Pro, and I am programming happily in F# on it. It has cut into my Pythonista time, another non-Apple made app.
Maybe Apple's focus more on hardware, and leaving software a bit behind is working out for them. It seems users are stepping up and creating some really productive software.
I have always lamented the lack of such automation techniques on Linux. Even though Linux systems are open and free software platforms, their desktop interfaces are ironically less programmable as compared to OSX and Windows.
My thoughts - It gives people powerful scriptability over things they couldn't control before. It has been refined down a few products/generations so its molded for more people to find it useful. It is free. Nobody is trying to sell anything or take anything away. So, maybe there is no need for any negativity.
Aha! Very cool; should look deeper. Don't know if there is any ultimate connection, but the fact that LuaJit and Torch7 go together invites exploration.
126 comments
[ 2.7 ms ] story [ 163 ms ] threadThen I can just put a Lua file in my dotfiles.
"HammerSpoon"
It perfectly conveys what an elegant kludge it is.
Suggestions for filling in the blank, are welcome :)
[0] https://en.wikipedia.org/wiki/Stone_Soup
As we added feature after feature to Mjolnir, and it grew to a monolithic collection of barely-related modules (APIs), I realized that it didn't make a lot of sense for users to keep upgrading to "newer" versions of Mjolnir, when in reality it was just the modules bundled with Mjolnir that were new or changed, and Mjolnir itself wasn't changed at all.
So I made the decision to decentralize the APIs. Instead of being bundled into Mjolnir itself, users would be able to download Mjolnir and then download or upgrade modules independently of Mjolnir.
This was pretty unpopular, because it meant Mjolnir was no longer "batteries included", so Hammerspoon was forked by the portion of the community that preferred that batteries included approach. Honestly, I don't even know how much of the community (if any) continued to use Mjolnir.
They forked it because of a difference of opinion: I believe that separation of the core app and the modules into separate projects is ultimately better, and they don't.
When they're separate projects, there's a lot of potential for really interesting tools to be built around them, between them, or bridging them together.
Imagine having a GUI app that manages third party modules for you, installing and loading them at a single click. Or a plugin that centralizes plugin settings into a unified single GUI window. These are the kinds of things that this separation was meant to allow and encourage.
But when it's a batteries-included app, every single aspect of it needs to be built into the app. It becomes monolithic. Every feature anyone could ever want needs to be bundled into it, and even though this is more convenient at first, it ends up bloated. It also doesn't allow for any competition between features in the same domain.
The authors behind Hammerspoon prefer the batteries-included approach. They're not wrong, it's not a matter of right or wrong. It's just a difference of opinion. People who want that approach will prefer Hammerspoon. People who want to build tools around their existing tools will probably prefer Mjolnir.
In this case, mjolnir, the lean mean core, then the various subprojects, and finally the "distro", containing a curated set of popular modules that people can download as a turnkey system. Then, if you want your own custom setup, minus the bloat, you can set up your own distro. If you just want to use the damn thing and don't care about how the sausage is made, use the "recommended" distro.
Have a centralized repository containing pointers to all available modules. Module creators can publish to this repository. Cocoapods does this rather nicely, and uses github for the centralized repo.
Then have a tool inside mjolnir that allows administration of the repo (request adding your module, publish a new version of your module, etc).
Then have a "distro" format that lists what modules are included in your distro. This is doubly cool because if you have to install another machine, you just call upon your distro, it installs everything and you're good to go. It also makes upgrading to the latest and greatest modules a breeze.
I guarantee that 90% of your users will just go with the "recommended" distro, but the developers will love you for making it a lot easier to contribute. It's all about lowering friction, for users, power users, and devs.
I've played around with Lua in Codea -- really liked it: https://github.com/TwoLivesLeft/Codea-Runtime
see also: https://itunes.apple.com/us/app/codea/id439571171?mt=8
[1] https://www.google.com/?q=autohotkey
I'm pretty fluent in Lua, so being able to leverage ability like Hammerspoon does would be great.
https://pywinauto.github.io/
Recently I've made this hammerspoon "plugin": https://github.com/selectnull/hammerspoon-alttab
I would love to have feedback, if anyone is interested (it's not perfect, i'm aware of few bugs, but it solves my problem most of the time).
Let me know if you make something.
Check out the really gentle follow-along tutorial:
http://www.hammerspoon.org/go/
I think we made some terrible API decisions, but we'll fix them up eventually!
(Also for those following along at home, sdegutis is the author of a long line of OS X automation tooling, up to and including Mjolnir, which we forked to make Hammerspoon. He is awesome)
Phoneix lives on as Phoenix 2.2 https://github.com/kasper/phoenix
I also have it iMessage me when it's removed. In case someone else grabs it when I'm not near it.
I also have it wake up the screen when I plug it in, combined with Knock I can get in and out of my computer quickly and easily.
In the original post, I left out that I also have a usb LED sign [1] that I also have programmed, so people know when they can and cannot interrupt me. Again controlled with hammerspoon and my yubikey.
[1] http://dreamcheeky.com/led-message-board
http://fanf.livejournal.com/139925.html
This (https://github.com/Linell/hammerspoon-config) is my configuration, which is about as basic as it gets. The documentation has a billion other, cooler things that can be done.
Look at emmet if you do anything involving html.
Maybe setup a process that watches a folder and builds/compiles anything placed in there.
If you need to do a job 10 times that takes 5 hours to do each time and you can automate that job in 30 hours so each job now only takes 1 hour each then you've saved 10 hours of time.
At my work I've made an enewsletter editor app (turned 2 week job down to 3 days job) and a language file editor for the content we output (turned 1 week job into 1 day job)
All that extra time gives you more breathing room between projects, more polish time for those projects or more time to learn new things.
Can people give some real world examples of what they are using this for?
CAPS + 1 = Bring up Bash
CAPS + 2 = Bring up IntelliJ
CAPS + 3 = Bring up Chrome
CAPS + 4 = Bring up Geany
CAPS + 5 = Bring up SourceTree
CAPS + F1 = Chat software
CAPS + F2 = Email
CAPS + F = Full screen the current app (But not really fullscreen - it's like option + green button, except width too)
CAPS + W = Cycle the wifi
CAPS + V = Paste text from the clipboard by typing it in, accounting for tab indentations. This is useful for copying things from Outlook into Confluence. Stupid Confluence.
https://github.com/victorso/.hammerspoon/blob/master/tools/c...
Here (https://github.com/Linell/hammerspoon-config) is my configuration, although it's nothing fancy.
cmd+alt+control+k emaKs cmd+alt+control+T Trello cmd+alt+control+M chroMe
And I have cmd+alt+control+/ print this bubble message onto the screen to help remember them all: https://fetchh--captured.s3.amazonaws.com/2016-07-15_135709....
I was a bit surprised, but cmd+fx doesn't seem to override any useful app builtin shortcuts either for the apps I use.
2. Site specific apps (e.g. trello)
3. Custom browser chooser per URL
4. Clipboard manager
5. Downloader manager
6. Various system information displays
7. Pomodoro timer
8. Various utilities.
Hammerspoon is the only utility that could give me what I wanted: Window columns sized ⅓ ⅔ on the left monitor, and ⅔ ⅓ on the right monitor.
- Drag to the left or right to cover that half of the screen. - Drag to the top for maximise - Drag to a corner for corner snap - Control + Option + Arrow to snap to left or right of screen, maximise or center - Control + Option + Command + Arrow to snap to corner of screen
https://gist.github.com/spartanatreyu/850788a0441e1c5565668a...
Spectacle just didn't have the window options and wasn't being actively developed to add the options that everyone was asking for.
It's the oldest issue (3 years) on the project:
https://github.com/eczarny/spectacle/issues/37
Use it nonstop all day to snap stuff half-screen right/left/up/down, no to mention (finally!) full screen.
Intrigued by Hammerspoon.
Edit: After binding a hotkey to hs.alert.show(_VERSION), it seems to be Lua 5.3.
Edit 2: Oh Hammerspoon has an interactive console. Typing _VERSION in there would have been slightly simpler.
I almost never use Dock, Spotlight or Finder now. It's great!
Wrap it all in a personal Cask, and you're good to go! https://github.com/Jeppesen-io/homebrew-hammerspoon
[1] https://support.apple.com/kb/PH21894?locale=en_US
Thankfully, tools like you've discovered address this behaviour and add a lot of other useful window management features anyway.
It seems like the Option+Click on the streetlight is kind of like a toggle of the last two previous sizes, but not always - sometimes it stretches to the top, sometimes it doesn't do anything.
I've been a dedicated OS X user since 10.3 - and, despite spending 15-20 minutes at a stretch every year or so (such as tonight) - I've never really understood what the green button is supposed to do. I kind of find it amazing that such a horribly inconsistent user interface control has persisted for 15+ years.
But yet - Magnet (much like Spectacle before it) does exactly what I want. Ctrl+Option+Enter = Maximize window (which is exactly what I bet 99% of people want the Green Button to do)
For example, you could make text editing (in apps that use the Cocoa text editor libraries and input fields etc..., which are most of them) act like Vim or Emacs, or Windows, or whatever you want.
It's useful both for general window management as well as system hackery. It's the closest OS X users can get to the power of Linux.
> It has a very low false negative rate, but often has false positives.
Seems like it would get triggered constantly around noises like A/C, or wind, or the inevitable coworker who quietly hisses behind you while you've got your headphones on.
(It would be me. I would 100% be that coworker.)
The answer is that all the false positives I encounter are human-triggered so if you are alone and not doing anything else except reading, they aren't much of an issue.
You can also buy super directional headsets that don't pick up anything else, even other people making the noises standing next to you. I have one and it works great, just not as convenient as the tiny mike on my earbuds.
Im going to change the events to activated/deactived so that I can leave the app on, but only change the screensaver when in use.
Another seemingly great product for Apple not by Apple. I just downloaded the app Continous to my iPad Pro, and I am programming happily in F# on it. It has cut into my Pythonista time, another non-Apple made app.
Maybe Apple's focus more on hardware, and leaving software a bit behind is working out for them. It seems users are stepping up and creating some really productive software.
Awesome work! (And if you haven't already, check out some of Steven's other projects. Very fun/interesting code.)