AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Hammerspoon scripts11/21/2023 ![]() Hammerspoon - Price: Free Desktop automation tool for macOS that allows you to write Lua scripts to control your Mac. Project mention: A collection of useful Mac Apps /r/macapps. Have fun controlling your windows from your iPad or iPhone. Staggeringly powerful macOS desktop automation with Lua. Does anyone have an idea why or an working example for any application I am using MacOS Big Sur 11.2. But at the same time, I am able to use app:getMenuItems() to retrieve the whole menu structure. This workflow is also set up with a Remote page as well. While the script is able to find Firefox, it is not able to find the menu item I am looking for. This assumes all window movements were done with Hammerspoon and this workflow functions. This command undoes the very last window move. Just be careful to get the name of the application correct! The user can create more in the same manner. I also created a hotkey for doing Expose on FoldingText. If the application has only one window, it will simply bring it to the front. It will then put all the windows back to their original position and bring the one selected to the foreground. When an application is selected, it will show all of it's windows in a matrix on the screen and ask the user for the coordinates of the one to show. This gives other workflows or scripts the ability to interact with Hammerspoon through Alfred. There is also an external trigger HammerspoonCommand that will pass whatever is sent in the trigger to Hammerspoon using the command processor as in "hs:command". Type in a command string and it will be sent to Hammerspoon directly! There is also a hotkey set to this value as an example. Therefore, to move the current window to the upper left most block in a 3x3 matric, you would do "hs:setgrid 0, 0, 1, 1". This requires you to put the x, y for a starting position in a 3x3 matrix for the current window. This snaps the current window to the closes grid box area. This moves the current window to the right half of the screen. This moves the current window to the left half of the screen. This moves the current window to the right 2/3 of the screen. This moves the current window to the left 1/3 of the screen. It shows greyed "zzz" when caffienate is disabled and red "zzz" if enabled. If the AnyBar workflow and program is installed properly, a caffienate status bar is now available. This nudges the current window to the right. This nudges the current window to the left. This opens the Hammerspoon console to the foreground. This tells Hammerspoon to reload the configuration file. This will work properly for all releases higher than 1.4. This will upgrade the installation instead of writing over the users code. The original is backed up into the users home directory as hs.orig. After that, everything should just work.Ĭonfigure Hammerspoon with the configuration file that this workflow needs. Once installed, reload Hammerspoon and run the "hs:install" to set the configuration file this workflow expects. Follow this layout and you can do many neat things with Hammerspoon.įirst off, download Hammerspoon from. This is just a sample of the things that can be done. ![]() This workflow is for running scripts using Hammerspoon to control your windows. ![]() Wrapping the snippet above in a function and binding it to a hotkey should cycle the currently focused application across your different monitors.This is a direct port of my Mjolnir Workflow. Set the focused window's new frame dimensions ![]() WindowFrame.w = ((windowFrame.w / focusedScreenFrame.w) * nextScreenFrame.w) WindowFrame.h = ((windowFrame.h / focusedScreenFrame.h) * nextScreenFrame.h) WindowFrame.y = ((((windowFrame.y - focusedScreenFrame.y) / focusedScreenFrame.h) * nextScreenFrame.h) + nextScreenFrame.y) WindowFrame.x = ((((windowFrame.x - focusedScreenFrame.x) / focusedScreenFrame.w) * nextScreenFrame.w) + nextScreenFrame.x) Calculate the coordinates of the window frame in the next screen and retain aspect ratio Local windowFrame = focusedWindow:frame() Hammerspoon Headspace This all started with Hyper. Local nextScreenFrame = focusedWindow:screen():next():frame() Hammerspoon: A Better, Better Hyper Key JI use Hammerspoon to enhance my OSX with custom UI and automations, while also creating 'monotasking' deep work environments to keep me focused. Local focusedScreenFrame = focusedWindow:screen():frame() Local focusedWindow = hs.window.focusedWindow() and the next screen's frame dimensions. The Hammerspoon API doesn't provide an explicit function for doing this, so you gotta roll out with a custom implementation to achieve this: - Get the focused window, its window frame dimensions, its screen frame dimensions, I've answered this in Reddit post here, but in case anyone comes across this question here's the answer: ![]()
0 Comments
Read More
Leave a Reply. |