From 274aaa1972e0ad10700f2e12f01ab4c25a2c8b31 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Fri, 24 Oct 2014 06:19:23 -0700 Subject: [PATCH] Add hyper key. --- dotfiles/slate.js | 3 ++ resources/com.googlecode.iterm2.plist | 6 ++-- resources/karabiner-hyper.xml | 17 ++++++++++++ resources/karabiner_config.sh | 13 +++++++++ tasks/osx.py | 40 +++++++++++++++++---------- 5 files changed, 61 insertions(+), 18 deletions(-) create mode 100644 resources/karabiner-hyper.xml create mode 100755 resources/karabiner_config.sh diff --git a/dotfiles/slate.js b/dotfiles/slate.js index 11f4152c..341dffa5 100644 --- a/dotfiles/slate.js +++ b/dotfiles/slate.js @@ -1,16 +1,19 @@ var hint = slate.op("hint", { "characters" : "ASDFGHJKLQWERTYUIOPCVBN" }); + var grid = slate.op("grid", { grids: { "1920x1080": {"width": 8, "height": 6} } }); +var hyper = ":ctrl;shift;alt;cmd"; slate.bindAll({ "esc:cmd": hint, "space:alt": grid }); +slate.bind("h" + hyper, grid); slate.configAll({ windowHintsIgnoreHiddenWindows: false, diff --git a/resources/com.googlecode.iterm2.plist b/resources/com.googlecode.iterm2.plist index daf0cc02..6a021836 100644 --- a/resources/com.googlecode.iterm2.plist +++ b/resources/com.googlecode.iterm2.plist @@ -5271,7 +5271,7 @@ NSWindow Frame UKCrashReporter 99 294 592 584 0 0 1440 878 NSWindow Frame iTerm Window 0 - 4 476 570 401 0 0 1440 877 + 4 446 717 431 0 0 1440 877 New Bookmarks @@ -6071,7 +6071,7 @@ SUHasLaunchedBefore SULastCheckTime - 2014-10-23T02:09:31Z + 2014-10-24T09:47:01Z SavePasteHistory Show Toolbelt @@ -6113,7 +6113,7 @@ WebKitDefaultFontSize 11 WebKitStandardFont - Lucida Grande + .Helvetica Neue DeskInterface WindowNumber WindowStyle diff --git a/resources/karabiner-hyper.xml b/resources/karabiner-hyper.xml new file mode 100644 index 00000000..5c0c84d9 --- /dev/null +++ b/resources/karabiner-hyper.xml @@ -0,0 +1,17 @@ + + + + Remap Right Command to Hyper + OS X doesn't have a Hyper. This maps PC Application Key to Control + Shift + Option + Command. + + imalison.right_command_to_hyper + + + --KeyToKey-- + KeyCode::COMMAND_R, + + KeyCode::COMMAND_L, + ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L + + + diff --git a/resources/karabiner_config.sh b/resources/karabiner_config.sh new file mode 100755 index 00000000..c9278542 --- /dev/null +++ b/resources/karabiner_config.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +cli=/Applications/Karabiner.app/Contents/Library/bin/karabiner + +$cli set mange.pc_app_to_hyper 1 +/bin/echo -n . +$cli set repeat.initial_wait 300 +/bin/echo -n . +$cli set repeat.wait 11 +/bin/echo -n . +$cli set imalison.right_command_to_hyper 1 +/bin/echo -n . +/bin/echo diff --git a/tasks/osx.py b/tasks/osx.py index 04f44675..b760729b 100644 --- a/tasks/osx.py +++ b/tasks/osx.py @@ -13,6 +13,7 @@ def all(ctx): brew_cask(ctx) setup_cocoa_emacs(ctx) enable_access_for_assistive_devices(ctx) + enable_hyper(ctx) osx_config(ctx) @@ -39,8 +40,7 @@ MISC = ("file-formula", "less", "openssh --with-brewed-openssl", "perl518", "rsync", "svn", "unzip", "docker", "boot2docker", "pandoc", "mercurial") CASKS = ('caffeine', 'flux', 'google-chrome', 'iterm2', 'spotify', 'synergy', - 'virtualbox', 'xquartz', 'slate', 'java', 'vlc', 'seil',) - + 'virtualbox', 'xquartz', 'slate', 'java', 'vlc', 'seil', 'karabiner') @ctask def osx_config(ctx): @@ -89,20 +89,30 @@ def enable_access_for_assistive_devices(ctx): for app in APPS_NEEDING_ASSISTIVE_DEVICE_ACCESS: app_string = '/Applications/{0}.app'.format(app) user_application = os.path.expanduser('~' + app_string) - if os.path.exists(user_application): - ctx.run( - 'zsh -c "source ~/.zshrc && ' - 'enable_access_for_assistive_devices \"{0}\""'.format( - user_application - ) - ) - if os.path.exists(app_string): - ctx.run( - 'zsh -c "source ~/.zshrc && ' - 'enable_access_for_assistive_devices \"{0}\""'.format( - app_string - ) + enable_access_if_exists(ctx, user_application) + enable_access_if_exists(ctx, app_string) + enable_access_if_exists("/Applications/Karabiner.app/Contents/Applications/Karabiner_AXNotifier.app") + + +def enable_access_if_exists(ctx, app_string): + if os.path.exists(app_string): + ctx.run( + 'zsh -c "source ~/.zshrc && ' + 'enable_access_for_assistive_devices \"{0}\""'.format( + app_string ) + ) + +@ctask +def enable_hyper(ctx): + source = '{0}/karabiner-hyper.xml'.format(util.RESOURCES_DIRECTORY) + destination = os.path.expanduser("~/Library/Application\\ Support/Karabiner/private.xml") + try: + ctx.run("rm {0}".format(destination)) + except: + pass + ctx.run("ln -s {0} {1}".format(source, destination)) + ctx.run("{0}/karabiner_config.sh".format(util.RESOURCES_DIRECTORY)) @ctask def get_command_line_tools(ctx):