![]() ![]() ![]() Hammerspoon also supports reloading its configuration files upon detecting changes. Hs.hotkey.bind(hyper, 'l', gridset(1, 0, 1, 2)) - right half Hs.hotkey.bind(hyper, 'k', hs.grid.maximizeWindow) Hs.hotkey.bind(hyper, 'h', gridset(0, 0, 1, 2)) - left half Hs.hotkey.bind(hyper, 'j', toNextScreen()) 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. Local UNAVAILABLE =hsimage.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. Local hseventtap = require( 'hs.eventtap ') Local hsdrawing = require( 'hs.drawing ') TODO: notice when a window gets sent to another space and rebuild the window list The user only has to click an Install window switcher button, no big deal. mapCmdTab is a callback function for every time a key is pressed. We set up a window switcher that switches between windows within the current space. TODO: uses hs.window.filter right now but would it be better to watch window creation / deletion / space-moving / etc with hs.uielement.watcher and keep some internal table up to date with that? So I wrote a function to download Hammerspoon.zip, unzip it in a temporary folder, move it to /Applications, write a and a inside the /.hammerspoon directory, launch Hammerspoon and wait for the websocket to be available. In order to use cmd+tab and shift+command+tab to switch windows, you need to use eventtap so that you can override the default app switcher hotkey. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |