Hs.hotkey.bind(hyper, 'k', hs.grid.maximizeWindow) Hs.hotkey.bind(hyper, 'h', gridset(0, 0, 1, 2)) - left half function to move window one screen left or back if it's already on theĬurrentWindow = hs.window.focusedWindow() Os.execute("open /Applications/iTerm.app")Ĭonfiguring Window Movement Hotkeys - a helper function that returns another function that resizes the current window Os.execute("/System/Library/CoreServices/Menu\\ Extras/nu/Contents/Resources/CGSession -suspend") These two actions can be bound to keys via: - locking Stuff I regularly want to do is get an iTerm open or locking the screen. I want to automate a few things via hotkeys. How to achieve that thou is left as an exercise for the interested reader -) Easy bits first - application launching This combination of keys might also be mapped to a single key by virtue of Karabiner, a cool program allowing arbitrary key remappings and much much. I also define that I want a window grid size of 2x2, with no margins: local hyper = I use a set of modifier keys for all of the hotkeys, let's call that set hyper. So let's have a look at that:įirst, Hammerspoon's config resides in the file ~/.hammerspoon/a. For me, these are arranging windows grid-like on screen and have e.g. However, if you have about 30min at hand, you can already hammer out a nice configuration for the things that are most important for you to automate or hotkey. The configuration (it basically comes with no defaults) can be a bit daunting in the beginning - in fact, I had stumbled upon Hammerspoon already some time ago but didn't invest the effort back then. The following code snippets have been heavily inspired (read: copied) by philipalexander's, tstirrat's and cmsj's Hammerspoon configs on Github and also by Tristan Hume's post on configuring Mjolnir, of which Hammerspoon is a fork. if Thunderbolt Display connected, put Xcode on that one and Mail on the internal one) watch the name and number of screens connected and position windows accordingly (e.g.unmount USB devices upon switching to battery power.switch sound on or off, depending on the available wifi networks.Just some examples of what you can do with Hammerspoon: Not only can you access that single API, but also check for USB devices, Wifi names, attached screens and so on - all controlable with small Lua scripts. nudge a window a bit to the right.Įnter Hammerspoon: First and foremost, Hammerspoon provides you with scriptable access to OSX's accessibility API - and whatever you do with that, you can bind to a hotkey. Lately I've been using Magnet (formerly known as Window Magnet, App Store, $4.99), which is pretty nice but I felt it is not using the concept of moving stuff around with the keyboard to the full extent: While you can surely put windows in one quadrant of the screen or something, there's no option to e.g. Pressing d will activate the layer with g and y.Īt each level, a helper text is shown, like which-key in emacs.Being a big fan of using the keyboard for everything and not touching the mouse more than necessary, I went through different OSX helper applications for helping to move windows around, aligning them on screen, etc. Here, pressing option+space activates the first layer with b, t, d (browser, terminal, domain respectively) hs.loadSpoon("RecursiveBinder") - Load the spoon Here is a minimal lua snippet on how to use it. I wrote a Medium article about how to use it to make a leader key for macOS. If you're still wondering how to do this, then the RecursiveBinder Spoon for Hammerspoon will do the trick.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |