├── .gitignore ├── alert.wav ├── init.lua └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .extcache 2 | Mjolnir.docset/ 3 | 4 | -------------------------------------------------------------------------------- /alert.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Linell/mjolnir-config/HEAD/alert.wav -------------------------------------------------------------------------------- /init.lua: -------------------------------------------------------------------------------- 1 | -- Load Extensions 2 | local application = require "mjolnir.application" 3 | local window = require "mjolnir.window" 4 | local hotkey = require "mjolnir.hotkey" 5 | local fnutils = require "mjolnir.fnutils" 6 | local alert = require "mjolnir.alert" 7 | local grid = require "mjolnir.bg.grid" 8 | -- Music controls 9 | local spotify = require "mjolnir.lb.spotify" 10 | local audiodevice = require "mjolnir._asm.sys.audiodevice" 11 | -- Sound and Notifications 12 | local sound = require "mjolnir._asm.ui.sound" 13 | local alert_sound = sound.get_byfile("alert.wav") 14 | local tink_sound = sound.get_byname("Tink") -- Not actually used, just as a nice example. 15 | -- More sounds in /System/Library/Sounds 16 | 17 | -- Set up hotkey combinations 18 | local mash = {"cmd", "alt", "ctrl"} 19 | local mashshift = {"cmd", "alt", "shift"} 20 | -- Set grid size. 21 | grid.GRIDWIDTH = 12 22 | grid.GRIDHEIGHT = 12 23 | grid.MARGINX = 0 24 | grid.MARGINY = 0 25 | 26 | local function opendictionary() 27 | alert.show("Lexicon, at your service.", 0.75) 28 | application.launchorfocus("Dictionary") 29 | end 30 | 31 | hotkey.bind(mash, 'D', opendictionary) 32 | 33 | hotkey.bind(mash, ';', function() grid.snap(window.focusedwindow()) end) 34 | hotkey.bind(mash, "'", function() fnutils.map(window.visiblewindows(), grid.snap) end) 35 | 36 | hotkey.bind(mash, '=', function() grid.adjustwidth(1) end) 37 | hotkey.bind(mash, '-', function() grid.adjustwidth(-1) end) 38 | hotkey.bind(mashshift, '=', function() grid.adjustheight(1) end) 39 | hotkey.bind(mashshift, '-', function() grid.adjustheight(-1) end) 40 | 41 | hotkey.bind(mashshift, 'left', function() window.focusedwindow():focuswindow_west() end) 42 | hotkey.bind(mashshift, 'right', function() window.focusedwindow():focuswindow_east() end) 43 | hotkey.bind(mashshift, 'up', function() window.focusedwindow():focuswindow_north() end) 44 | hotkey.bind(mashshift, 'down', function() window.focusedwindow():focuswindow_south() end) 45 | 46 | hotkey.bind(mash, 'M', grid.maximize_window) 47 | hotkey.bind(mashshift, 'M', function() window.focusedwindow():minimize() end) 48 | 49 | hotkey.bind(mash, 'F', function() window.focusedwindow():setfullscreen(true) end) 50 | hotkey.bind(mashshift, 'F', function() window.focusedwindow():setfullscreen(false) end) 51 | 52 | hotkey.bind(mash, 'N', grid.pushwindow_nextscreen) 53 | hotkey.bind(mash, 'P', grid.pushwindow_prevscreen) 54 | 55 | hotkey.bind(mash, 'J', grid.pushwindow_down) 56 | hotkey.bind(mash, 'K', grid.pushwindow_up) 57 | hotkey.bind(mash, 'H', grid.pushwindow_left) 58 | hotkey.bind(mash, 'L', grid.pushwindow_right) 59 | 60 | hotkey.bind(mash, 'U', grid.resizewindow_taller) 61 | hotkey.bind(mash, 'O', grid.resizewindow_wider) 62 | hotkey.bind(mash, 'I', grid.resizewindow_thinner) 63 | hotkey.bind(mash, 'Y', grid.resizewindow_shorter) 64 | 65 | hotkey.bind(mashshift, 'space', spotify.displayCurrentTrack) 66 | hotkey.bind(mashshift, 'P', spotify.play) 67 | hotkey.bind(mashshift, 'O', spotify.pause) 68 | hotkey.bind(mashshift, 'N', spotify.next) 69 | hotkey.bind(mashshift, 'I', spotify.previous) 70 | 71 | hotkey.bind(mashshift, 'T', function() alert.show(os.date("%A %b %d, %Y - %I:%M%p"), 4) end) 72 | 73 | hotkey.bind(mashshift, ']', function() audiodevice.defaultoutputdevice():setvolume(audiodevice.current().volume + 5) end) 74 | hotkey.bind(mashshift, '[', function() audiodevice.defaultoutputdevice():setvolume(audiodevice.current().volume - 5) end) 75 | 76 | alert_sound:play() 77 | alert.show("Mjolnir, at your service.", 3) 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Mjolnir Configuration 2 | 3 | [Mjolnir](https://github.com/mjolnir-io/mjolnir) is a lightweight automation and 4 | productivity app for OS X. It's the spiritual successor of Hydra, my previous 5 | window manager. 6 | 7 | --- 8 | 9 | ### Installation 10 | 11 | Make sure that you've got Mjolnir installed. Try to make sure you can run a simple init.lua 12 | before you continue, just to ensure everything is ship shape. Once you're ready, 13 | 14 | ```bash 15 | git clone https://github.com/Linell/mjolnir-config.git ~/.mjolnir 16 | cd ~/.mjolnir 17 | luarocks install mjolnir.application 18 | luarocks install mjolnir.window 19 | luarocks install mjolnir.hotkey 20 | luarocks install mjolnir.fnutils 21 | luarocks install mjolnir.alert 22 | luarocks install mjolnir.bg.grid 23 | luarocks install mjolnir.lb.spotify 24 | luarocks install mjolnir._asm.sys.audiodevice 25 | luarocks install mjolnir._asm.ui.sound 26 | ``` 27 | 28 | Now go up to the hammer icon in your menu, click it, and select 'Reload Config'. 29 | 30 | You should get a fancy "Mjolnir, at your service" message and cool alert noise. Boom, 31 | installation complete. 32 | 33 | ### Usage 34 | 35 | You should definitely check out `init.lua` for the full "how to use" experience. That's where 36 | all of the usage is defined, after all. For a brief breakdown though, here's what does what: 37 | 38 | * "mash" refers to pressing ⌘ + ⌥ + ⌃ at once. 39 | * "mashshift" refers to pressing ⌘ + ⌥ + ⇧ at once. 40 | 41 | | Key Combination | Description | 42 | | ------------------------------- | ------------------------------------------------------------------------------------------------------ | 43 | | mash + D | Opens the OS X dictionary. | 44 | | mash + ; | Snaps the focused window to the grid. | 45 | | mash + ' | Snaps *all* visible windows to the grid. | 46 | | mash + = | Adds a column to the width of the grid. | 47 | | mash + - | Removes a column from the width of the grid. | 48 | | mashshift + = | Adds a row to the height of the grid. | 49 | | mashshift + - | Removes a row from the height of the grid. | 50 | | mashshift + | Focuses on the window to the left of the current window. | 51 | | mashshift + | Focuses on the window to the right of the current window. | 52 | | mashshift + | Focuses on the window above the current window. | 53 | | mashshift + | Focuses on the window below the current window. | 54 | | mash + M | Maximize the current window. | 55 | | mashshift + M | Minimize the current window. | 56 | | mash + F | Make the current window fullscreen. | 57 | | mashshift + F | Make the current window *not* fullscreen. | 58 | | mash + N | Pushes the current window to the next monitor. | 59 | | mash + P | Pushes the current window to the previous monitor. | 60 | | mash + U | Makes the current window taller. Only works if there is room for the window to get bigger downward. | 61 | | mash + O | Makes the current window wider. Only works if there is room for the window to get bigger to the right. | 62 | | mash + I | Makes the window thinner, from right to left. | 63 | | mash + Y | Makes the window shorter, from bottom to top. | 64 | | mashshift + spacebar | Display currently playing song in Spotify. | 65 | | mashshift + P | Start playing Spotify. | 66 | | mashshift + O | Pause Spotify. | 67 | | mashshift + N | Skip to next song on Spotify. | 68 | | mashshift + I | Skip to previous song on Spotify. | 69 | | mashshift + ] | Increase volume by increment of 5 | 70 | | mashshift + [ | Decrease volume by increment of 5 | 71 | | mashshift + T | Shows the current date and time. | 72 | 73 | Hopefully that'll help you get a jump start on what everything does! 74 | 75 | --------------------------------------------------------------------------------