├── README.md
├── alert.wav
└── init.lua
/README.md:
--------------------------------------------------------------------------------
1 | ## Hammerspoon Configuration
2 |
3 | [Hammerspoon](http://www.hammerspoon.org/) is a tool for powerful automation of OS X.
4 | Hammerspoon gets its power from a set of extensions that expose specific system functionality
5 | to the user.
6 |
7 | ---
8 |
9 | ### Installation
10 |
11 | You can follow the [Hammerspoon getting started guide](http://www.hammerspoon.org/go/) to
12 | get everything set up. Once you've got it downloaded and a basic config working, so that you
13 | know that everything is working, follow these steps:
14 |
15 | ```bash
16 | git clone git@github.com:Linell/hammerspoon-config.git ~/.hammerspoon
17 | ```
18 |
19 | Now go up to the hammer icon in your menu, click it, and select 'Reload Config'.
20 |
21 | You should get a fancy "Hammerspoon, at your service" message and cool alert noise. Boom,
22 | installation complete. Note that you made need to make `alert.wav` executable -- `chmod 777 alert.wav` may help.
23 |
24 | ### Usage
25 |
26 | You should definitely check out `init.lua` for the full "how to use" experience. That's where
27 | all of the usage is defined, after all. For a brief breakdown though, here's what does what:
28 |
29 | * "mash" refers to pressing ⌘ + ⌥ + ⌃ at once.
30 | * "mashshift" refers to pressing ⌘ + ⌥ + ⇧ at once.
31 |
32 | | Key Combination | Description |
33 | | ------------------------------- | ------------------------------------------------------------------------------------------------------ |
34 | | mash + ; | Snaps the focused window to the grid. |
35 | | mash + ' | Snaps *all* visible windows to the grid. |
36 | | mash + = | Adds a column to the width of the grid. |
37 | | mash + - | Removes a column from the width of the grid. |
38 | | mashshift + = | Adds a row to the height of the grid. |
39 | | mashshift + - | Removes a row from the height of the grid. |
40 | | mashshift + ← | Focuses on the window to the left of the current window. |
41 | | mashshift + → | Focuses on the window to the right of the current window. |
42 | | mashshift + ↑ | Focuses on the window above the current window. |
43 | | mashshift + ↓ | Focuses on the window below the current window. |
44 | | mash + M | Maximize the current window. |
45 | | mash + F | Make the current window fullscreen. |
46 | | mashshift + F | Make the current window *not* fullscreen. |
47 | | mash + N | Pushes the current window to the next monitor. |
48 | | mash + P | Pushes the current window to the previous monitor. |
49 | | mash + U | Makes the current window taller. Only works if there is room for the window to get bigger downward. |
50 | | mash + O | Makes the current window wider. Only works if there is room for the window to get bigger to the right. |
51 | | mash + I | Makes the window thinner, from right to left. |
52 | | mash + Y | Makes the window shorter, from bottom to top. |
53 | | mashshift + spacebar | Display currently playing song in Spotify. |
54 | | mashshift + P | Start playing Spotify. |
55 | | mashshift + O | Pause Spotify. |
56 | | mashshift + N | Skip to next song on Spotify. |
57 | | mashshift + I | Skip to previous song on Spotify. |
58 | | mashshift + ] | Increase volume by increment of 5 |
59 | | mashshift + [ | Decrease volume by increment of 5 |
60 | | mashshift + T | Shows the current date and time. |
61 |
62 | Hopefully that'll help you get a jump start on what everything does!
63 |
64 |
--------------------------------------------------------------------------------
/alert.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Linell/hammerspoon-config/2f74daaba5db177709162df9074fbc86b8cf9899/alert.wav
--------------------------------------------------------------------------------
/init.lua:
--------------------------------------------------------------------------------
1 | local alert_sound = hs.sound.getByFile("alert.wav")
2 | local tink_sound = hs.sound.getByName("Tink") -- Not actually used, just as a nice example.
3 | -- More sounds in /System/Library/Sounds
4 |
5 | -- Set up hotkey combinations
6 | local mash = {"cmd", "alt", "ctrl"}
7 | local mashshift = {"cmd", "alt", "shift"}
8 | local funkymash = {"cmd", "ctrl", "shift"}
9 |
10 | -- Set grid size.
11 | hs.grid.GRIDWIDTH = 12
12 | hs.grid.GRIDHEIGHT = 12
13 | hs.grid.MARGINX = 0
14 | hs.grid.MARGINY = 0
15 | -- Set window animation off. It's much smoother.
16 | hs.window.animationDuration = 0
17 | -- Set volume increments
18 | local volumeIncrement = 5
19 |
20 | hs.hotkey.bind(mash, ';', function() hs.grid.snap(hs.window.focusedWindow()) end)
21 | hs.hotkey.bind(mash, "'", function() hs.fnutils.map(hs.window.visibleWindows(), hs.grid.snap) end)
22 |
23 | hs.hotkey.bind(mash, '=', function() hs.grid.adjustWidth(1) end)
24 | hs.hotkey.bind(mash, '-', function() hs.grid.adjustWidth(-1) end)
25 | hs.hotkey.bind(mashshift, '=', function() hs.grid.adjustHeight(1) end)
26 | hs.hotkey.bind(mashshift, '-', function() hs.grid.adjustHeight(-1) end)
27 |
28 | hs.hotkey.bind(mashshift, 'left', function() hs.window.focusedWindow():focusWindowWest() end)
29 | hs.hotkey.bind(mashshift, 'right', function() hs.window.focusedWindow():focusWindowEast() end)
30 | hs.hotkey.bind(mashshift, 'up', function() hs.window.focusedWindow():focusWindowNorth() end)
31 | hs.hotkey.bind(mashshift, 'down', function() hs.window.focusedWindow():focusWindowSouth() end)
32 |
33 | hs.hotkey.bind(mash, 'M', hs.grid.maximizeWindow)
34 |
35 | hs.hotkey.bind(mash, 'F', function() hs.window.focusedWindow():toggleFullScreen() end)
36 |
37 | hs.hotkey.bind(mash, 'N', hs.grid.pushWindowNextScreen)
38 | hs.hotkey.bind(mash, 'P', hs.grid.pushWindowPrevScreen)
39 |
40 | hs.hotkey.bind(mash, 'J', hs.grid.pushWindowDown)
41 | hs.hotkey.bind(mash, 'K', hs.grid.pushWindowUp)
42 | hs.hotkey.bind(mash, 'H', hs.grid.pushWindowLeft)
43 | hs.hotkey.bind(mash, 'L', hs.grid.pushWindowRight)
44 |
45 | hs.hotkey.bind(mash, 'U', hs.grid.resizeWindowTaller)
46 | hs.hotkey.bind(mash, 'O', hs.grid.resizeWindowWider)
47 | hs.hotkey.bind(mash, 'I', hs.grid.resizeWindowThinner)
48 | hs.hotkey.bind(mash, 'Y', hs.grid.resizeWindowShorter)
49 |
50 | hs.hotkey.bind(mashshift, 'space', hs.spotify.displayCurrentTrack)
51 | hs.hotkey.bind(mashshift, 'P', hs.spotify.play)
52 | hs.hotkey.bind(mashshift, 'O', hs.spotify.pause)
53 | hs.hotkey.bind(mashshift, 'N', hs.spotify.next)
54 | hs.hotkey.bind(mashshift, 'I', hs.spotify.previous)
55 |
56 | hs.hotkey.bind(funkymash, 'space', hs.itunes.displayCurrentTrack)
57 | hs.hotkey.bind(funkymash, 'P', hs.itunes.play)
58 | hs.hotkey.bind(funkymash, 'O', hs.itunes.pause)
59 | hs.hotkey.bind(funkymash, 'N', hs.itunes.next)
60 | hs.hotkey.bind(funkymash, 'I', hs.itunes.previous)
61 |
62 | hs.hotkey.bind(mashshift, 'T', function() hs.alert.show(os.date("%A %b %d, %Y - %I:%M%p"), 4) end)
63 |
64 | hs.hotkey.bind(mashshift, ']', function() hs.audiodevice.defaultOutputDevice():setVolume(hs.audiodevice.current().volume + 5) end)
65 | hs.hotkey.bind(mashshift, '[', function() hs.audiodevice.defaultOutputDevice():setVolume(hs.audiodevice.current().volume - 5) end)
66 |
67 | alert_sound:play()
68 | hs.alert.show("Hammerspoon, at your service.", 3)
69 |
--------------------------------------------------------------------------------