├── README.md ├── linux └── kanata │ ├── README.md │ └── caps2esc.kbd └── macos ├── kanata ├── README.md ├── caps2esc.kbd └── io.dreamsofcode.kanata.plist └── karabiner └── caps2esc.json /README.md: -------------------------------------------------------------------------------- 1 | # Escape Control 2 | 3 | This repo contains supplementary information about the Dreams of Code video titled: 4 | 5 | "Changing the worst keyboard key into my most useful one." 6 | 7 | ## MacOS 8 | 9 | As I mentioned in the video, my previous tool for modifying the capslock key was Karabiner-Elements, which is incredibly capable. 10 | 11 | You can find the configuration I used under ./macOS/karabiner 12 | 13 | Now, I use Kanata, you can find a configuration that also supports function row keys (minus Mission control, dnd and a couple of others) under 14 | macOS/kanata 15 | 16 | ## Linux 17 | 18 | My goto used to be caps2esc which is a pretty awesome package. You can find more information on it's repo. 19 | 20 | Now, I mainly use Kanata on Nix, which is what I use on my laptops, you can find my nixOS configuration on my dotfiles repo at elliottminns/dotfiles 21 | 22 | If you want to set up Kanata as a service on a systemd based system, then you can view the config at linux/kanata which will have both the systemd file 23 | and the caps2esc kanata configuration that you can use. 24 | -------------------------------------------------------------------------------- /linux/kanata/README.md: -------------------------------------------------------------------------------- 1 | # Linux 2 | 3 | ## Systemd daemon process 4 | 5 | Then add this to: `~/.config/systemd/user/kanata.service`: 6 | 7 | ``` 8 | [Unit] 9 | Description=Kanata keyboard remapper 10 | Documentation=https://github.com/jtroo/kanata 11 | 12 | [Service] 13 | Environment=PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:$HOME/.cargo/bin 14 | Environment=DISPLAY=:0 15 | Type=simple 16 | ExecStart=/usr/bin/sh -c 'exec $$(which kanata) --cfg $${HOME}/.config/kanata/config.kbd' 17 | Restart=no 18 | 19 | [Install] 20 | WantedBy=default.target 21 | ``` 22 | 23 | Then run 24 | 25 | ``` 26 | systemctl --user daemon-reload 27 | systemctl --user enable kanata.service 28 | systemctl --user start kanata.service 29 | systemctl --user status kanata.service # check whether the service is running 30 | ``` 31 | 32 | For more information use the following install guide found at: 33 | 34 | https://github.com/jtroo/kanata/blob/main/docs/setup-linux.md 35 | -------------------------------------------------------------------------------- /linux/kanata/caps2esc.kbd: -------------------------------------------------------------------------------- 1 | ;; Caps to escape/control configuration for Kanata 2 | 3 | (defsrc 4 | caps 5 | ) 6 | 7 | (defalias 8 | escctrl (tap-hold 100 100 esc lctl) 9 | ) 10 | 11 | (deflayer base 12 | @escctrl 13 | ) 14 | -------------------------------------------------------------------------------- /macos/kanata/README.md: -------------------------------------------------------------------------------- 1 | # Kanata 2 | 3 | This directory contains the kanata configuration for macOS, as well as a 4 | launchctl configuration to enable this to run as a LaunchAgent or LaunchDaemon. 5 | 6 | To do so, make some modifications to the launch configuration or create your 7 | own named `com.example.kanata.plist` 8 | 9 | You'll need to replace the label string and the path to kanata and the config depeneding on your own system configuration. 10 | 11 | ```xml 12 | 13 | 14 | 15 | 16 | Label 17 | com.example.kanata 18 | 19 | ProgramArguments 20 | 21 | {{ path to kanata }} 22 | -c 23 | {{ path to config }} 24 | 25 | 26 | RunAtLoad 27 | 28 | 29 | KeepAlive 30 | 31 | 32 | StandardOutPath 33 | /Library/Logs/Kanata/kanata.out.log 34 | 35 | StandardErrorPath 36 | /Library/Logs/Kanata/kanata.err.log 37 | 38 | 39 | ``` 40 | 41 | Then, copy this file to your LaunchDaemon folder. 42 | 43 | 44 | ``` 45 | sudo cp ./com.example.kanata.plist /Library/LaunchDaemon 46 | ``` 47 | 48 | Once copied over, you can then load it using sudo 49 | 50 | ``` 51 | sudo launchctl load /Library/LaunchDaemons/com.example.kanata.plist 52 | sudo launchctl start com.example.kanata 53 | ``` 54 | 55 | Now, kanata should be running whenever your macbook starts up! 56 | 57 | If you use multiple keyboards, you may want to limit this to only showing up on your MacBooks internal keyboard. 58 | -------------------------------------------------------------------------------- /macos/kanata/caps2esc.kbd: -------------------------------------------------------------------------------- 1 | ;; Caps to escape/control configuration for Kanata 2 | 3 | (defsrc 4 | f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 5 | caps 6 | ) 7 | 8 | ;; Definine two aliases, one for esc/control to other for function key 9 | (defalias 10 | escctrl (tap-hold 100 100 esc lctl) 11 | ) 12 | 13 | (deflayer base 14 | brdn brup _ _ _ _ prev pp next mute vold volu 15 | @escctrl 16 | ) 17 | 18 | (deflayer fn 19 | f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 20 | @escctrl 21 | ) 22 | -------------------------------------------------------------------------------- /macos/kanata/io.dreamsofcode.kanata.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | io.dreamsofcode.kanata 7 | 8 | ProgramArguments 9 | 10 | /Users/elliott/.cargo/bin/kanata 11 | -c 12 | /Users/elliott/.dotfiles/.config/kanata/kanata.kbd 13 | 14 | 15 | RunAtLoad 16 | 17 | 18 | KeepAlive 19 | 20 | 21 | StandardOutPath 22 | /Library/Logs/Kanata/kanata.out.log 23 | 24 | StandardErrorPath 25 | /Library/Logs/Kanata/kanata.err.log 26 | 27 | 28 | -------------------------------------------------------------------------------- /macos/karabiner/caps2esc.json: -------------------------------------------------------------------------------- 1 | { 2 | "description": "Change caps_lock to left_control if pressed with other keys, change caps_lock to escape if pressed alone.", 3 | "manipulators": [ 4 | { 5 | "from": { 6 | "key_code": "caps_lock", 7 | "modifiers": { 8 | "optional": [ 9 | "any" 10 | ] 11 | } 12 | }, 13 | "to": [ 14 | { 15 | "key_code": "left_control", 16 | "lazy": true 17 | } 18 | ], 19 | "to_if_alone": [ 20 | { 21 | "key_code": "escape" 22 | } 23 | ], 24 | "type": "basic" 25 | } 26 | ] 27 | } 28 | --------------------------------------------------------------------------------