Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS Sierra Support #10

Merged
merged 93 commits into from
Jan 28, 2017
Merged

macOS Sierra Support #10

merged 93 commits into from
Jan 28, 2017

Conversation

jasonrudolph
Copy link
Owner

@jasonrudolph jasonrudolph commented Dec 16, 2016

This setup has historically relied heavily on Karabiner. According to the Karabiner site:

Karabiner does not work on macOS Sierra at the moment.

We are developing Karabiner-Elements which provides simple key modification for macOS Sierra at first. (Karabiner-Elements works well on macOS Sierra. We are working on fixing several remaining issues.)

We'll start updating for the full featured Karabiner for Sierra after Karabiner-Elements is completed.

I have high hopes for all a full-featured Karabiner coming to Sierra 🤞, but in the meantime, I'd ❤️ to have as much of this setup working on Sierra as possible.

This branch represents a work-in-progress attempt to port the majority of this repository's pre-Sierra functionality to Sierra. Presently, the tools available on Sierra lack the power and flexibility available in Karabiner. Given those limitations, porting the previous functionality to Sierra will likely involve compromises. It's unlikely to be an exact port.

TODO

  • A more useful caps lock
    • Tap caps lock for escape
    • Hold caps lock for control
  • Enable navigation via the home row (See README 📝)
    • Left/down/up/right
    • Previous/next word
      • In most apps
      • In iTerm2
    • Start/end of line
    • Page down/up
    • Select while navigating
    • Delete previous/next word
    • Delete to start/end of line
  • Enable other commonly-used actions on or near the home row (See README 📝)
    • Previous/next tab
    • First/last tab
    • Split panes horizontally/vertically in iTerm2
    • Move left/up/down/right by one pane in iTerm2
  • Window management using keyboard shortcuts on or near the home row
    • Send window left (left half of screen) - control + s, h
    • Send window down (bottom half of screen) - control + s, j
    • Send window up (top half of screen) - control + s, k
    • Send window right (right half of screen) - control + s, l
    • Send window to upper left - control + s, i
    • Send window to upper right - control + s, o
    • Send window to lower left - control + s, ,
    • Send window to lower right - control + s, .
    • Send window to center of screen - control + s, space
    • Resize window to fill the screen - control + s, enter
    • Send window to next monitor - control + s, n
  • Hyper key for quickly launching apps
    • Use right option key as hyper key
    • hyper + a to open iTunes ("A" for "Apple Music")
    • hyper + b to open Google Chrome ("B" for "Browser")
    • hyper + c to open Hackable Slack Client ("C for "Chat")
    • hyper + d to open Remember The Milk ("D" for "Do!" ... or "Done!")
    • hyper + e to open Atom Beta ("E" for "Editor")
    • hyper + f to open Finder ("F" for "Finder")
    • hyper + g to open Mailplane 3 ("G" for "Gmail")
    • hyper + t to open iTerm ("T" for "Terminal")
  • Markdown formatting
    • Italics (Wrap the currently-selected text in single asterisks) - control + m, i
    • Bold (Wrap the currently-selected text in double asterisks) - control + m, b
    • Strikethrough (Wrap the currently-selected text in double tildes - control + m, s
    • Inline link (Convert the currently-selected text to an inline link, using a URL from the clipboard) - control + m, l
  • Consider providing visual indicator when in (S)uper (D)uper Mode, WindowLayout Mode, and Markdown Mode
  • Update README

Karabiner doesn't currently run on macOS Sierra. Until it does, perhaps
we can use Karabiner-Elements and Hammerspoon to get the functionality
that we used to get from Karabiner. For starters, let's configure caps
lock so that we can:

- Tap caps lock for escape
- Press caps lock plus and another key to trigger *control* plus that
  other key (e.g., "caps lock + e" to trigger "control + e" to move to
  the end of the line)

Depends on:

- Hammperspoon (http://www.hammerspoon.org)
- Karabiner-Elements (https://github.com/tekezo/Karabiner-Elements)
Credit goes to https://github.com/rtoshiro/hammerspoon-init for the
comments used to visually describe the window layouts.
caps lock + r needs to be available in the terminal to trigger
control + r. So, change the keybinding that's used to reload the
hammerspoon config from caps lock + r to caps lock + `, and make
caps lock + r trigger control + r.
- Translate h/j/k/l to up/down/left/right.
- When caps lock is held down, treat 'a' as 'alt' and 's' as 'command'.
  Therefore, for example, when pressing caps lock plus 's' plus 'h', it
  becomes 'command' plus 'left'.
- Add support for core (S)uper (D)uper Mode features.
- Remove similar features from BetterCapsLock Mode. This frees us to use
  caps lock as control in more situations (e.g., we'll be able to
  translate caps lock + a to conrol + a to go to the beginning of the
  line).
@jasonrudolph
Copy link
Owner Author

3fb5e77 adds support for "(S)uper (D)uper Mode" on macOS Sierra. Most of the pre-Sierra features are available:

(S)uper (D)uper Mode

To activate, push the s and d keys simultaneously and hold them down. Now you're in (S)uper (D)uper mode. It's like a secret keyboard inside your keyboard. (Whoa.) It's optimized for keeping you on the home row, or very close to it. Now you can:

  • Use h/j/k/l for up/down/left/right respectively
  • Use a for alt (AKA option)
  • Use f for command
  • Use space for shift
  • Use a + j/k for page up/page down
  • Use i/o to move to the previous/next tab
  • Use a + h/l to move to previous/next word in most apps (but not yet in iTerm2)

Prior to Sierra, this functionality ☝️ relied on Karabiner's Simultaneous VI Mode. Since Karabiner-Elements doesn't yet support Simultaneous VI Mode, this pull request implements the functionality via Hammerspoon.


/fyi @pengwynn @adamyonk @spicycode: This might be of interest to you. ⌨️ :neckbeard:

Hammerspoon doesn't appear to have a way to indicate which screen should
receive the drawing. It seems to always go to the primary screen. If you
connect or disconnect a monitor while Hammerspoon is running, your
primary screen may change. Since we use the dimensions of the primary
screen to calculate the coordinates for the status message, and since
the coordinates of the primary screen can change, we need to dynamically
determine the coordinates of the status message each time we display it
(or, we need to recalculate the coordinates any time the primary screen
changes). For now, the easiest approach seems to be to lazily construct
the status message drawings each time we need to display them.
Prior to this change, yubiswitch couldn't disable the yubikey. With this
change, yubiswitch can once again enable/disable the yubikey.
@jasonrudolph
Copy link
Owner Author

I'm not yet using this branch full-time, so it's too soon to say whether this implementation will feel natural when used on a daily basis. -- #10 (comment)

Update: I've started using this branch full-time, with mostly positive results. So far, I'm only noticing one issue:

(S)uper (D)uper mode occasionally fails to trigger some actions. For example, if I hit i to move to the previous tab, it usually works, but sometimes it doesn't. 🤔 In the Hammerspoon console, the log shows that we triggered the command+shift+[ keystroke to move to the previous tab, but the app (Chrome, Finder, Atom, etc.) doesn't actually move to the previous tab. If I try again, it works. @adamyonk: Have you observed this issue? Have you noticed any other issues?

I'll continue using this branch for the rest of this week. If things go smoothly, I'll move on to updating the README, and then I'll merge this branch.

@adamyonk
Copy link
Contributor

Pulled down the latest this morning, it's working great! I especially like the super duper and window layout mode notifications. Regarding your tab-switching bugginess comment, I noticed that switching tabs would get tripped up for me if the tab I switched to had focus on an input when I left it - that input would start capturing everything instead of continuing to move between tabs. I'm not sure if there would even be a way to keep that from happening, but I wonder if that was why it was happening for you? Anyway, it is working splendidly for me - awesome work!

3598ce5 and 45ad832 added a hotkey to exit WindowLayout Mode and
Markdown Mode respectively. But, that original implementation created a
new binding for the hotkey every time the mode was entered. Therefore,
if you entered WindowLayout Mode n times, you end up with n hotkey
bindings for exiting WindowLayout Mode. After a while, WindowLayout Mode
would get really slow, due to all the setup time required to setup and
teardown each of those many bindings. 😓

With the changes in this commit, we only create the binding once. 😅
We don't seem to be getting any benefit from using the lower-level
approach, so let's switch to using hs.eventtap.keyStroke.
@jasonrudolph jasonrudolph merged commit a15cdfb into master Jan 28, 2017
@jasonrudolph jasonrudolph deleted the sierra branch January 28, 2017 15:06
@jasonrudolph
Copy link
Owner Author

@adamyonk: Thanks for all your testing and feedback this pull request. Your enthusiasm and support made this even more fun! 🍻 If you notice any issues or have any feedback, I'm all ears. 💟

@jasonrudolph
Copy link
Owner Author

Now that this pull request is merged, if anyone is looking for the pre-Sierra bits, the v1.0.0 release is suitable for use on OS X El Capitan (10.11), and it probably works on OS X Yosemite (10.10) and OS X Mavericks (10.9) as well.

The changes in this pull request (which are present in the new v2.0.0 release), are suitable for use on macOS Sierra (10.12) and OS X El Capitan (10.11).

✌️

@gvaughn
Copy link

gvaughn commented Mar 8, 2017

I'm over a month late, but a big 👍 and thank you @jasonrudolph. I currently rely on parts of this in El Capitan and have delayed upgrading to Sierra because of it. Now I have a clear path. Much appreciated.

@duff
Copy link

duff commented Mar 8, 2017

I'm really digging the project too!

@narze
Copy link
Contributor

narze commented Aug 6, 2017

Wow. Just found this just after I go all the way to solve it in hardware level! 🙈
Now I can get back to use my Macbook's keyboard now. Thank you! 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants