Uncategorized

Hacking the Caps Lock Key Part 2

Using the caps lock key for windows arrangement management

caps_lock_shift

In my previous blog post, I talked about mapping the caps lock key to the hyper key [Control+Shift+Command+Option] and using that to create shortcuts for launching and switching between applications. Today I’d like to share how to use the same caps lock key to quickly move and resize windows to better organize what’s on your screen.

I became a Mac user in 2010 and haven’t looked back since. But the one feature I’ve always been jealous of on my friend’s Windows computer was the “split screen” feature and easily being able to see two or more applications at the same time. (El Capitan now supports this feature too!) I want to take it a step further and do this without moving my cursor.

hammerspoon_demo_gif

Using Hammerspoon and Lua scripts to move windowshammerspoon

  • http://www.hammerspoon.org/
  • Download Hammerspoon and move it to Applications
  • Make sure to enable the “Launch Hammerspoon at login” option and allow accessibility from “System Preference -> Security & Privacy”
  • スクリーンショット 2015-12-08 午後8.30.08
  • I’m going to be working off of Tim Stirrat’s configs https://github.com/tstirrat/hammerspoon-config
  • Open your terminal and execute the following commands
  • git clone http://github.com/tstirrat/hammerspoon-config.git ~/.hammerspoon
    cd ~/.hammerspoon
    cp config.example.lua config.lua
  • As of 2015/12/08, it seems like this fix hasn’t been merged yet, https://github.com/justone/hammerspoon-config/commit/3d8e1409db5bb6bfed87a30e3ce6e7f64d68f01c so we are just going to go ahead and modify ~/.hammerspoon/utils/match_dialogue.lua to be the following
  • スクリーンショット 2015-12-08 11.32.43 PM
  • Now let’s open Hammerspoon and reload the configs. You can do this with [Command+Shift+R] or going to “File->Reload Config”
  • After you’ve reloaded Hammerspoon successfully, hold down [Control+Option+Command] and press any arrow key. You should now be able move around the windows!
  • But we still need to hold down 4 keys… Let’s change the configs so we can move the windows by just using the caps lock
  • Edit ~/.hammerspoon/modules/arrows.lua so it looks like the following

  • Reload Hammerspoon again and you’ll notice that [Caps Lock+arrow key] will shift your window to whatever direction you choose.
  • I use a pretty big monitor at work, so I also added the following
    • [Caps Lock + 1] → top right quadrant
    • [Caps Lock + 2] →  bottom right quadrant
    • [Caps Lock + 3] →  bottom left quadrant
    • [Caps Lock + 4] →  top left quadrant
    • [Caps Lock + 7] →  left 1/3
    • [Caps Lock + 8] → center 1/3
    • [Caps Lock + 9] → right 1/3
    • [Caps Lock + Space] → Full screen but not “FULL SCREEN” that hides everything else
  • I’ve also updated ~/.hammerspoon/modules/monitors.lua so I can move my windows from screen to screen when I use external monitors

  • I don’t use the caps lock key here, but [Control+Common+{left|right}] will move my current active window to whichever external monitor I desire

 

As you can see, Hammerspoon is very light weight yet powerful and can do much much more. These configurations are also what’s worked for me so you should explore and find what feels most natural to you. Happy hacking!

Discussion

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s