From abfbd65725ba45d0b7d17eca114574ed0be4de3c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 4 Apr 2018 14:44:25 -0700 Subject: add some osx config karabiner, bettertouchtool, amethyst, hammerspoon --- Makefile | 2 + .../complex_modifications/command-escape.json | 32 + .../assets/complex_modifications/number-row.json | 390 +++++++++ .../complex_modifications/other-remapping.json | 200 +++++ .../complex_modifications/terminal-overrides.json | 135 +++ config/karabiner/karabiner.json | 920 +++++++++++++++++++++ .../Spoons/ReloadConfiguration.spoon/docs.json | 90 ++ .../Spoons/ReloadConfiguration.spoon/init.lua | 49 ++ hammerspoon/Spoons/SpeedMenu.spoon/docs.json | 39 + hammerspoon/Spoons/SpeedMenu.spoon/init.lua | 111 +++ hammerspoon/init.lua | 29 + plists/com.amethyst.Amethyst.plist | Bin 0 -> 12811 bytes plists/com.hegenberg.BetterTouchTool.plist | Bin 0 -> 14224 bytes 13 files changed, 1997 insertions(+) create mode 100644 config/karabiner/assets/complex_modifications/command-escape.json create mode 100644 config/karabiner/assets/complex_modifications/number-row.json create mode 100644 config/karabiner/assets/complex_modifications/other-remapping.json create mode 100644 config/karabiner/assets/complex_modifications/terminal-overrides.json create mode 100644 config/karabiner/karabiner.json create mode 100644 hammerspoon/Spoons/ReloadConfiguration.spoon/docs.json create mode 100644 hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua create mode 100644 hammerspoon/Spoons/SpeedMenu.spoon/docs.json create mode 100644 hammerspoon/Spoons/SpeedMenu.spoon/init.lua create mode 100644 hammerspoon/init.lua create mode 100644 plists/com.amethyst.Amethyst.plist create mode 100644 plists/com.hegenberg.BetterTouchTool.plist diff --git a/Makefile b/Makefile index 4b50080..4edafa4 100644 --- a/Makefile +++ b/Makefile @@ -40,9 +40,11 @@ INSTALL = agignore \ zshrc \ abook \ bin \ + config/karabiner \ dzil \ fortune \ gnupg \ + hammerspoon \ i3 \ mpdscribble \ ncmpcpp \ diff --git a/config/karabiner/assets/complex_modifications/command-escape.json b/config/karabiner/assets/complex_modifications/command-escape.json new file mode 100644 index 0000000..03c6167 --- /dev/null +++ b/config/karabiner/assets/complex_modifications/command-escape.json @@ -0,0 +1,32 @@ +{ + "title": "Map Command to Escape when pressed alone", + "rules": [ + { + "manipulators": [ + { + "description": "Map left command to escape", + "type": "basic", + "from": { + "key_code": "left_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_command", + "lazy": true + } + ], + "to_if_alone": [ + { + "key_code": "escape" + } + ] + } + ] + } + ] +} diff --git a/config/karabiner/assets/complex_modifications/number-row.json b/config/karabiner/assets/complex_modifications/number-row.json new file mode 100644 index 0000000..f56166b --- /dev/null +++ b/config/karabiner/assets/complex_modifications/number-row.json @@ -0,0 +1,390 @@ +{ + "title": "Exchange numbers and symbols", + "rules": [ + { + "description": "Exchange numbers and symbols (1234567890 and !@#$%^&*())", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "1", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "1", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "2", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "2", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "3", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "3", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "4", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "4", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "5", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "5", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "6", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "6", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "7", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "7", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "8", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "8", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "9", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "9", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "0", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "0", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "1", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "1" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "2", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "2" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "3", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "3" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "4", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "4" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "5", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "5" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "6", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "6" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "7", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "7" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "8", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "8" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "9", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "9" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "0", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "0" + } + ] + } + ] + } + ] +} diff --git a/config/karabiner/assets/complex_modifications/other-remapping.json b/config/karabiner/assets/complex_modifications/other-remapping.json new file mode 100644 index 0000000..b817219 --- /dev/null +++ b/config/karabiner/assets/complex_modifications/other-remapping.json @@ -0,0 +1,200 @@ +{ + "title": "Other keyboard remappings", + "rules": [ + { + "description": "Other keyboard remappings", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "grave_accent_and_tilde", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "grave_accent_and_tilde", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "grave_accent_and_tilde", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "grave_accent_and_tilde" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "hyphen", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "hyphen", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "hyphen", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "hyphen" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "open_bracket", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "open_bracket", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "open_bracket", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "open_bracket" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "close_bracket", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "close_bracket", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "close_bracket", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "close_bracket" + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "backslash", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "backslash", + "modifiers": [ + "left_shift" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "backslash", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "backslash" + } + ] + } + ] + } + ] +} diff --git a/config/karabiner/assets/complex_modifications/terminal-overrides.json b/config/karabiner/assets/complex_modifications/terminal-overrides.json new file mode 100644 index 0000000..f15ac37 --- /dev/null +++ b/config/karabiner/assets/complex_modifications/terminal-overrides.json @@ -0,0 +1,135 @@ +{ + "title": "Terminal overrides", + "rules": [ + { + "description": "Swap command and control in terminal applications", + "manipulators": [ + { + "type": "basic", + "from": { + "key_code": "left_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_control", + "lazy": true + } + ], + "to_if_alone": [ + { + "key_code": "escape" + } + ], + "conditions": [ + { + "type": "frontmost_application_if", + "bundle_identifiers": [ + "^com\\.apple\\.Terminal$", + "^com\\.googlecode\\.iterm2$", + "^co\\.zeit\\.hyperterm$", + "^co\\.zeit\\.hyper$", + "^io\\.alacritty$", + "^net\\.kovidgoyal\\.kitty$" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "left_control", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_command", + "lazy": true + } + ], + "conditions": [ + { + "type": "frontmost_application_if", + "bundle_identifiers": [ + "^com\\.apple\\.Terminal$", + "^com\\.googlecode\\.iterm2$", + "^co\\.zeit\\.hyperterm$", + "^co\\.zeit\\.hyper$", + "^io\\.alacritty$", + "^net\\.kovidgoyal\\.kitty$" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "right_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_control", + "lazy": true + } + ], + "conditions": [ + { + "type": "frontmost_application_if", + "bundle_identifiers": [ + "^com\\.apple\\.Terminal$", + "^com\\.googlecode\\.iterm2$", + "^co\\.zeit\\.hyperterm$", + "^co\\.zeit\\.hyper$", + "^io\\.alacritty$", + "^net\\.kovidgoyal\\.kitty$" + ] + } + ] + }, + { + "type": "basic", + "from": { + "key_code": "right_control", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_command", + "lazy": true + } + ], + "conditions": [ + { + "type": "frontmost_application_if", + "bundle_identifiers": [ + "^com\\.apple\\.Terminal$", + "^com\\.googlecode\\.iterm2$", + "^co\\.zeit\\.hyperterm$", + "^co\\.zeit\\.hyper$", + "^io\\.alacritty$", + "^net\\.kovidgoyal\\.kitty$" + ] + } + ] + } + ] + } + ] +} diff --git a/config/karabiner/karabiner.json b/config/karabiner/karabiner.json new file mode 100644 index 0000000..94c145a --- /dev/null +++ b/config/karabiner/karabiner.json @@ -0,0 +1,920 @@ +{ + "global": { + "check_for_updates_on_startup": true, + "show_in_menu_bar": true, + "show_profile_name_in_menu_bar": false + }, + "profiles": [ + { + "complex_modifications": { + "parameters": { + "basic.simultaneous_threshold_milliseconds": 50, + "basic.to_delayed_action_delay_milliseconds": 500, + "basic.to_if_alone_timeout_milliseconds": 500, + "basic.to_if_held_down_threshold_milliseconds": 200 + }, + "rules": [ + { + "description": "Swap command and control in terminal applications", + "manipulators": [ + { + "conditions": [ + { + "bundle_identifiers": [ + "^com\\.apple\\.Terminal$", + "^com\\.googlecode\\.iterm2$", + "^co\\.zeit\\.hyperterm$", + "^co\\.zeit\\.hyper$", + "^io\\.alacritty$", + "^net\\.kovidgoyal\\.kitty$" + ], + "type": "frontmost_application_if" + } + ], + "from": { + "key_code": "left_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_control", + "lazy": true + } + ], + "to_if_alone": [ + { + "key_code": "escape" + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "bundle_identifiers": [ + "^com\\.apple\\.Terminal$", + "^com\\.googlecode\\.iterm2$", + "^co\\.zeit\\.hyperterm$", + "^co\\.zeit\\.hyper$", + "^io\\.alacritty$", + "^net\\.kovidgoyal\\.kitty$" + ], + "type": "frontmost_application_if" + } + ], + "from": { + "key_code": "left_control", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_command", + "lazy": true + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "bundle_identifiers": [ + "^com\\.apple\\.Terminal$", + "^com\\.googlecode\\.iterm2$", + "^co\\.zeit\\.hyperterm$", + "^co\\.zeit\\.hyper$", + "^io\\.alacritty$", + "^net\\.kovidgoyal\\.kitty$" + ], + "type": "frontmost_application_if" + } + ], + "from": { + "key_code": "right_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_control", + "lazy": true + } + ], + "type": "basic" + }, + { + "conditions": [ + { + "bundle_identifiers": [ + "^com\\.apple\\.Terminal$", + "^com\\.googlecode\\.iterm2$", + "^co\\.zeit\\.hyperterm$", + "^co\\.zeit\\.hyper$", + "^io\\.alacritty$", + "^net\\.kovidgoyal\\.kitty$" + ], + "type": "frontmost_application_if" + } + ], + "from": { + "key_code": "right_control", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "right_command", + "lazy": true + } + ], + "type": "basic" + } + ] + }, + { + "manipulators": [ + { + "description": "Map left command to escape", + "from": { + "key_code": "left_command", + "modifiers": { + "optional": [ + "any" + ] + } + }, + "to": [ + { + "key_code": "left_command", + "lazy": true + } + ], + "to_if_alone": [ + { + "key_code": "escape" + } + ], + "type": "basic" + } + ] + }, + { + "description": "Exchange numbers and symbols (1234567890 and !@#$%^&*())", + "manipulators": [ + { + "from": { + "key_code": "1", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "1", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "2", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "2", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "3", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "3", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "4", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "4", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "5", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "5", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "6", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "6", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "7", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "7", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "8", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "8", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "9", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "9", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "0", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "0", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "1", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "1" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "2", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "2" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "3", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "3" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "4", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "4" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "5", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "5" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "6", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "6" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "7", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "7" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "8", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "8" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "9", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "9" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "0", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "0" + } + ], + "type": "basic" + } + ] + }, + { + "description": "Other keyboard remappings", + "manipulators": [ + { + "from": { + "key_code": "grave_accent_and_tilde", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "grave_accent_and_tilde", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "grave_accent_and_tilde", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "grave_accent_and_tilde" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "hyphen", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "hyphen", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "hyphen", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "hyphen" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "open_bracket", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "open_bracket", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "open_bracket", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "open_bracket" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "close_bracket", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "close_bracket", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "close_bracket", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "close_bracket" + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "backslash", + "modifiers": { + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "backslash", + "modifiers": [ + "left_shift" + ] + } + ], + "type": "basic" + }, + { + "from": { + "key_code": "backslash", + "modifiers": { + "mandatory": [ + "shift" + ], + "optional": [ + "caps_lock" + ] + } + }, + "to": [ + { + "key_code": "backslash" + } + ], + "type": "basic" + } + ] + } + ] + }, + "devices": [ + { + "disable_built_in_keyboard_if_exists": false, + "fn_function_keys": [], + "identifiers": { + "is_keyboard": true, + "is_pointing_device": false, + "product_id": 361, + "vendor_id": 1241 + }, + "ignore": false, + "manipulate_caps_lock_led": false, + "simple_modifications": [ + { + "from": { + "key_code": "left_command" + }, + "to": { + "key_code": "left_option" + } + }, + { + "from": { + "key_code": "left_option" + }, + "to": { + "key_code": "left_command" + } + }, + { + "from": { + "key_code": "right_option" + }, + "to": { + "key_code": "right_command" + } + }, + { + "from": { + "key_code": "right_command" + }, + "to": { + "key_code": "right_option" + } + } + ] + } + ], + "fn_function_keys": [ + { + "from": { + "key_code": "f1" + }, + "to": { + "consumer_key_code": "mute" + } + }, + { + "from": { + "key_code": "f2" + }, + "to": { + "consumer_key_code": "volume_decrement" + } + }, + { + "from": { + "key_code": "f3" + }, + "to": { + "consumer_key_code": "volume_increment" + } + }, + { + "from": { + "key_code": "f4" + }, + "to": { + "key_code": "vk_none" + } + }, + { + "from": { + "key_code": "f5" + }, + "to": { + "consumer_key_code": "display_brightness_decrement" + } + }, + { + "from": { + "key_code": "f6" + }, + "to": { + "consumer_key_code": "display_brightness_increment" + } + }, + { + "from": { + "key_code": "f7" + }, + "to": { + "key_code": "vk_none" + } + }, + { + "from": { + "key_code": "f8" + }, + "to": { + "key_code": "f8" + } + }, + { + "from": { + "key_code": "f9" + }, + "to": { + "key_code": "vk_none" + } + }, + { + "from": { + "key_code": "f10" + }, + "to": { + "key_code": "f18" + } + }, + { + "from": { + "key_code": "f11" + }, + "to": { + "key_code": "vk_none" + } + }, + { + "from": { + "key_code": "f12" + }, + "to": { + "key_code": "vk_none" + } + } + ], + "name": "Default profile", + "selected": true, + "simple_modifications": [ + { + "from": { + "key_code": "caps_lock" + }, + "to": { + "key_code": "fn" + } + } + ], + "virtual_hid_keyboard": { + "caps_lock_delay_milliseconds": 0, + "keyboard_type": "ansi" + } + } + ] +} diff --git a/hammerspoon/Spoons/ReloadConfiguration.spoon/docs.json b/hammerspoon/Spoons/ReloadConfiguration.spoon/docs.json new file mode 100644 index 0000000..50c62f2 --- /dev/null +++ b/hammerspoon/Spoons/ReloadConfiguration.spoon/docs.json @@ -0,0 +1,90 @@ +[ + { + "Command": [], + "Constant": [], + "Constructor": [], + "Deprecated": [], + "Field": [], + "Function": [], + "Method": [ + { + "def": "ReloadConfiguration:bindHotkeys(mapping)", + "desc": "Binds hotkeys for ReloadConfiguration", + "doc": "Binds hotkeys for ReloadConfiguration\n\nParameters:\n * mapping - A table containing hotkey modifier/key details for the following items:\n * reloadConfiguration - This will cause the configuration to be reloaded", + "name": "bindHotkeys", + "parameters": [ + " * mapping - A table containing hotkey modifier/key details for the following items:", + " * reloadConfiguration - This will cause the configuration to be reloaded" + ], + "signature": "ReloadConfiguration:bindHotkeys(mapping)", + "stripped_doc": "", + "type": "Method" + }, + { + "def": "ReloadConfiguration:start()", + "desc": "Start ReloadConfiguration", + "doc": "Start ReloadConfiguration\n\nParameters:\n * None", + "name": "start", + "parameters": [ + " * None" + ], + "signature": "ReloadConfiguration:start()", + "stripped_doc": "", + "type": "Method" + } + ], + "Variable": [ + { + "def": "ReloadConfiguration.watch_paths", + "desc": "List of directories to watch for changes, defaults to hs.configdir", + "doc": "List of directories to watch for changes, defaults to hs.configdir", + "name": "watch_paths", + "signature": "ReloadConfiguration.watch_paths", + "stripped_doc": "", + "type": "Variable" + } + ], + "desc": "Adds a hotkey to reload the hammerspoon configuration, and a pathwatcher to automatically reload on changes.", + "doc": "Adds a hotkey to reload the hammerspoon configuration, and a pathwatcher to automatically reload on changes.\n\nDownload: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/ReloadConfiguration.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/ReloadConfiguration.spoon.zip)", + "items": [ + { + "def": "ReloadConfiguration:bindHotkeys(mapping)", + "desc": "Binds hotkeys for ReloadConfiguration", + "doc": "Binds hotkeys for ReloadConfiguration\n\nParameters:\n * mapping - A table containing hotkey modifier/key details for the following items:\n * reloadConfiguration - This will cause the configuration to be reloaded", + "name": "bindHotkeys", + "parameters": [ + " * mapping - A table containing hotkey modifier/key details for the following items:", + " * reloadConfiguration - This will cause the configuration to be reloaded" + ], + "signature": "ReloadConfiguration:bindHotkeys(mapping)", + "stripped_doc": "", + "type": "Method" + }, + { + "def": "ReloadConfiguration:start()", + "desc": "Start ReloadConfiguration", + "doc": "Start ReloadConfiguration\n\nParameters:\n * None", + "name": "start", + "parameters": [ + " * None" + ], + "signature": "ReloadConfiguration:start()", + "stripped_doc": "", + "type": "Method" + }, + { + "def": "ReloadConfiguration.watch_paths", + "desc": "List of directories to watch for changes, defaults to hs.configdir", + "doc": "List of directories to watch for changes, defaults to hs.configdir", + "name": "watch_paths", + "signature": "ReloadConfiguration.watch_paths", + "stripped_doc": "", + "type": "Variable" + } + ], + "name": "ReloadConfiguration", + "stripped_doc": "\nDownload: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/ReloadConfiguration.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/ReloadConfiguration.spoon.zip)", + "submodules": [], + "type": "Module" + } +] \ No newline at end of file diff --git a/hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua b/hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua new file mode 100644 index 0000000..bb83f67 --- /dev/null +++ b/hammerspoon/Spoons/ReloadConfiguration.spoon/init.lua @@ -0,0 +1,49 @@ +--- === ReloadConfiguration === +--- +--- Adds a hotkey to reload the hammerspoon configuration, and a pathwatcher to automatically reload on changes. +--- +--- Download: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/ReloadConfiguration.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/ReloadConfiguration.spoon.zip) + +local obj = {} +obj.__index = obj + +-- Metadata +obj.name = "ReloadConfiguration" +obj.version = "1.0" +obj.author = "Jon Lorusso " +obj.homepage = "https://github.com/Hammerspoon/Spoons" +obj.license = "MIT - https://opensource.org/licenses/MIT" + + +--- ReloadConfiguration.watch_paths +--- Variable +--- List of directories to watch for changes, defaults to hs.configdir +obj.watch_paths = { hs.configdir } + +--- ReloadConfiguration:bindHotkeys(mapping) +--- Method +--- Binds hotkeys for ReloadConfiguration +--- +--- Parameters: +--- * mapping - A table containing hotkey modifier/key details for the following items: +--- * reloadConfiguration - This will cause the configuration to be reloaded +function obj:bindHotkeys(mapping) + local def = { reloadConfiguration = hs.fnutils.partial(hs.reload, self) } + hs.spoons.bindHotkeysToSpec(def, mapping) +end + +--- ReloadConfiguration:start() +--- Method +--- Start ReloadConfiguration +--- +--- Parameters: +--- * None +function obj:start() + self.watchers = {} + for _,dir in pairs(self.watch_paths) do + self.watchers[dir] = hs.pathwatcher.new(dir, hs.reload):start() + end + return self +end + +return obj diff --git a/hammerspoon/Spoons/SpeedMenu.spoon/docs.json b/hammerspoon/Spoons/SpeedMenu.spoon/docs.json new file mode 100644 index 0000000..f57b965 --- /dev/null +++ b/hammerspoon/Spoons/SpeedMenu.spoon/docs.json @@ -0,0 +1,39 @@ +[ + { + "Command": [], + "Constant": [], + "Constructor": [], + "Deprecated": [], + "Field": [], + "Function": [], + "Method": [ + { + "def": "SpeedMenu:rescan()", + "desc": "Redetect the active interface, darkmode …And redraw everything.", + "doc": "Redetect the active interface, darkmode …And redraw everything.\n", + "name": "rescan", + "signature": "SpeedMenu:rescan()", + "stripped_doc": "", + "type": "Method" + } + ], + "Variable": [], + "desc": "Menubar netspeed meter", + "doc": "Menubar netspeed meter\n\nDownload: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/SpeedMenu.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/SpeedMenu.spoon.zip)", + "items": [ + { + "def": "SpeedMenu:rescan()", + "desc": "Redetect the active interface, darkmode …And redraw everything.", + "doc": "Redetect the active interface, darkmode …And redraw everything.\n", + "name": "rescan", + "signature": "SpeedMenu:rescan()", + "stripped_doc": "", + "type": "Method" + } + ], + "name": "SpeedMenu", + "stripped_doc": "\nDownload: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/SpeedMenu.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/SpeedMenu.spoon.zip)", + "submodules": [], + "type": "Module" + } +] \ No newline at end of file diff --git a/hammerspoon/Spoons/SpeedMenu.spoon/init.lua b/hammerspoon/Spoons/SpeedMenu.spoon/init.lua new file mode 100644 index 0000000..d4ecdac --- /dev/null +++ b/hammerspoon/Spoons/SpeedMenu.spoon/init.lua @@ -0,0 +1,111 @@ +--- === SpeedMenu === +--- +--- Menubar netspeed meter +--- +--- Download: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/SpeedMenu.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/SpeedMenu.spoon.zip) + +local obj={} +obj.__index = obj + +-- Metadata +obj.name = "SpeedMenu" +obj.version = "1.0" +obj.author = "ashfinal " +obj.homepage = "https://github.com/Hammerspoon/Spoons" +obj.license = "MIT - https://opensource.org/licenses/MIT" + +function obj:init() + self.menubar = hs.menubar.new() + obj:rescan() +end + +local function data_diff() + local in_seq = hs.execute(obj.instr) + local out_seq = hs.execute(obj.outstr) + local in_diff = in_seq - obj.inseq + local out_diff = out_seq - obj.outseq + if in_diff/1024 > 1024 then + obj.kbin = string.format("%6.2f", in_diff/1024/1024) .. ' mb/s' + else + obj.kbin = string.format("%6.2f", in_diff/1024) .. ' kb/s' + end + if out_diff/1024 > 1024 then + obj.kbout = string.format("%6.2f", out_diff/1024/1024) .. ' mb/s' + else + obj.kbout = string.format("%6.2f", out_diff/1024) .. ' kb/s' + end + local disp_str = '⥄ ' .. obj.kbout .. '\n⥂ ' .. obj.kbin + if obj.darkmode then + obj.disp_str = hs.styledtext.new(disp_str, {font={size=9.0, color={hex="#FFFFFF"}}}) + else + obj.disp_str = hs.styledtext.new(disp_str, {font={size=9.0, color={hex="#000000"}}}) + end + obj.menubar:setTitle(obj.disp_str) + obj.inseq = in_seq + obj.outseq = out_seq +end + +--- SpeedMenu:rescan() +--- Method +--- Redetect the active interface, darkmode …And redraw everything. +--- + +function obj:rescan() + obj.interface = hs.network.primaryInterfaces() + obj.darkmode = hs.osascript.applescript('tell application "System Events"\nreturn dark mode of appearance preferences\nend tell') + local menuitems_table = {} + if obj.interface then + -- Inspect active interface and create menuitems + local interface_detail = hs.network.interfaceDetails(obj.interface) + if interface_detail.AirPort then + local ssid = interface_detail.AirPort.SSID + table.insert(menuitems_table, { + title = "SSID: " .. ssid, + tooltip = "Copy SSID to clipboard", + fn = function() hs.pasteboard.setContents(ssid) end + }) + end + if interface_detail.IPv4 then + local ipv4 = interface_detail.IPv4.Addresses[1] + table.insert(menuitems_table, { + title = "IPv4: " .. ipv4, + tooltip = "Copy IPv4 to clipboard", + fn = function() hs.pasteboard.setContents(ipv4) end + }) + end + if interface_detail.IPv6 then + local ipv6 = interface_detail.IPv6.Addresses[1] + table.insert(menuitems_table, { + title = "IPv6: " .. ipv6, + tooltip = "Copy IPv6 to clipboard", + fn = function() hs.pasteboard.setContents(ipv6) end + }) + end + local macaddr = hs.execute('ifconfig ' .. obj.interface .. ' | grep ether | awk \'{print $2}\'') + table.insert(menuitems_table, { + title = "MAC Addr: " .. macaddr, + tooltip = "Copy MAC Address to clipboard", + fn = function() hs.pasteboard.setContents(macaddr) end + }) + -- Start watching the netspeed delta + obj.instr = 'netstat -ibn | grep -e ' .. obj.interface .. ' -m 1 | awk \'{print $7}\'' + obj.outstr = 'netstat -ibn | grep -e ' .. obj.interface .. ' -m 1 | awk \'{print $10}\'' + + obj.inseq = hs.execute(obj.instr) + obj.outseq = hs.execute(obj.outstr) + + if obj.timer then + obj.timer:stop() + obj.timer = nil + end + obj.timer = hs.timer.doEvery(1, data_diff) + end + table.insert(menuitems_table, { + title = "Rescan Network Interfaces", + fn = function() obj:rescan() end + }) + obj.menubar:setTitle("⚠︎") + obj.menubar:setMenu(menuitems_table) +end + +return obj diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua new file mode 100644 index 0000000..c6b2b73 --- /dev/null +++ b/hammerspoon/init.lua @@ -0,0 +1,29 @@ +hs.loadSpoon("ReloadConfiguration") +spoon.ReloadConfiguration:start() + +hs.loadSpoon("SpeedMenu") + +hs.hotkey.bind({"alt"}, "h", function() + hs.window.focusedWindow():focusWindowWest(nil, false, true) +end) +hs.hotkey.bind({"alt"}, "j", function() + hs.window.focusedWindow():focusWindowSouth(nil, false, true) +end) +hs.hotkey.bind({"alt"}, "k", function() + hs.window.focusedWindow():focusWindowNorth(nil, false, true) +end) +hs.hotkey.bind({"alt"}, "l", function() + hs.window.focusedWindow():focusWindowEast(nil, false, true) +end) + +menubar = hs.menubar.new() +timer = hs.timer.doEvery(1, function() + hs.host.cpuUsage(function(cpu) + local cpuUsage = cpu["overall"]["active"] + menubar:setTitle(math.floor(cpuUsage + 0.5) .. "%") + end) +end) + +hs.caffeinate.set("systemIdle", true, true) + +hs.alert("Hammerspoon config reloaded") diff --git a/plists/com.amethyst.Amethyst.plist b/plists/com.amethyst.Amethyst.plist new file mode 100644 index 0000000..15e9a6a Binary files /dev/null and b/plists/com.amethyst.Amethyst.plist differ diff --git a/plists/com.hegenberg.BetterTouchTool.plist b/plists/com.hegenberg.BetterTouchTool.plist new file mode 100644 index 0000000..a91a7d0 Binary files /dev/null and b/plists/com.hegenberg.BetterTouchTool.plist differ -- cgit v1.2.3-54-g00ecf