AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Github hammerspoon11/5/2023 ![]() I personally don't know enough about Apple APIs (or even Lua for that matter) to implement a fix myself, so I'm kind of just stuck until someone with the experience is able to take a look at it. It looks like the issue has been around for 3 months now, and nobody's looked at it. I can't rotate screens, and it looks like I'm not the only one with this issue ( #3041). I ran into my first issue within a few minutes. My main use cases for it was to automate moving screens arounds and rotating them, as well as moving windows around from screen to screen. '.' elseif string.len ( newEntry ) < obj.I've got Hammerspoon installed on my new Macbook Pro 14" with an M1 Pro. funcName - make sure each entry is of the same length if string.len ( newEntry ) > obj.helperEntryLengthInChar then newEntry = string.sub ( newEntry, 1, obj.helperEntryLengthInChar - 2 ). Function to compare two letters - It sorts according to the ASCII code, and for letters, it will be alphabetical - However, for capital letters (65-90), I'm adding 32.5 (this came from 97 - 65 + 0.5, where 97 is a and 65 is A) to the ASCII code before comparing - This way, each capital letter comes after the corresponding simple letter but before letters that come after it in the alphabetical order local function compareLetters ( a, b ) asciiA = te ( a ) asciiB = te ( b ) if asciiA >= 65 and asciiA = 65 and asciiB '. A function called compareLetters is added, and the beginning of the for loop(in showHelper), and the part just before it are changed as shown The following code is to be added to RecursiveBinder.spoon/a.To fix this, I added some more code to sort the helper text before showing. If you used this, you may have noticed that the order of the keys in the helper text is not consistent.One to reload the config, and the other to open the config in VSCode Bonus Sorted helper text Here, I’ve also included a couple of keybindings for Hammerspoon. For example, singleKey('o', 'open') returns, 'space', spoon.RecursiveBinder.This is a convenience function used to easily create a table representing a keybinding with no modifiers, and also automatically translate capital letters to normal letters with shift modifier.Your ~/.hammerspoon directory should now look something like this:.It turned out that there was a Spoon for Hammerspoon called RecursiveBinder that could do the same thing. It wasn’t that long since I had been introduced to Vim, and I was getting comfortable with the leader key system.But I soon hit a roadblock where I was using up all the keys (or at least the most easily accessible ones) When I first started configuring Hammerspoon, I set up a hyper key, and added a few keybindings.Now let’s jump into the RecursiveBinder Spoon RecursiveBinder Spoon About And you can find many resources out there about setting up various things using Hammerspoon. You can also find ‘Spoons’, which are basically plugins which provide additional functionality, at this link. And if you want to know more about any part of the API, you will find that it is very well documented. You can go to Hammerspoon’s Getting started guide to see some more examples. show ( "Connected to Wi-Fi network", "", net, "" ) end end ) wifiwatcher : start () More ![]() show ( "You lost Wi-Fi connection", "", "", "" ) else hs.notify. currentNetwork () if net = nil then hs.notify. watcher.new ( function () local net = hs.wifi. ![]() You can replace the modifier combination with a hyper key if you want ![]() The following are a couple of basic examples of what you can do with Hammerspoon.You can split your config into separate files (and you should, if you do any serious configuring), and then use the require function to import them This is the starting point of your config.Using either Homebrew or from the website Configuring Setup Basically, you’re only limited by your imagination (and your skill at writing the relevant code). It has numerous APIs for macOS functionality, and with it, you can control pretty much whatever you want to. Simply put, it is an automation tool running on Lua. Eventually, I gained an interest in configuring my system to suit me better, and I came across Hammerspoon. I won’t go into what that was like here, as there are many people on the internet who have told their stories of learning Vim. However, since I am doing a CS degree, I needed to get familiar with programming related tools, and that is how I found Vim. I do still occasionally boot into Windows, using Bootcamp, but it’s only when I need to use some software that doesn’t run on macOS.Īt first, I used macOS much like I used to use Windows. Once I moved to macOS, it took quite some time to get used to it. I have used Ubuntu a bit, but that barely counts. Before that, I had only ever known Windows. I’ve been using macOS for a little over a year now.
0 Comments
Read More
Leave a Reply. |