# keyswitch

Lightweight keyboard layout switcher and shortcut manager for MacOS.

- Switches keyboard layouts with a single keypress INSTANTLY

- Written in Rust - small and fast

- Optionally, allows to run custom commands with key combinations

## Installation

### Rustaceans

```
cargo install keyswitch
```

(you may still need a symlink to `~/.cargo/bin/keyswitch` to see it in Finder
for Input Monitoring permission)

### Non-Rustaceans

Download a pre-built binary from `Releases` section and place it e.g. to `~/bin`.

## Setup

- Run `keyswitch setup`

- All instructions are printed in the terminal, but just in case:

- It will create a configuration file at `~/.config/keyswitch/config.toml`

- Add the binary path in `System Preferences -> Privacy & Security -> Input
  Monitoring`

- Use `keyswitch edit-config` to open the configuration file in the default terminal
  editor. Or edit `~/.config/keyswitch/config.toml manually`

- To get key codes and modifiers, run `keyswitch sniff`, important: the terminal
  app must also have Input Monitoring permission (at least until the setup is
  over)

- Start `keyswitch` in the terminal to ensure it works

- Run `launchctl load /Users/gigabito/Library/LaunchAgents/ai.bma.keyswitch.plist` to
  start it in background and have it started on login

## Updating

- Replace the binary

- Remove and add again the Input Monitoring permission

## Troubleshooting

- add to `~/Library/LaunchAgents/ai.bma.keyswitch.plist`:

```
<key>StandardOutPath</key>
<string>/tmp/keyswitch.out</string>
<key>StandardErrorPath</key>
<string>/tmp/keyswitch.err</string>
```

- check `/tmp/keyswitch.out` and `/tmp/keyswitch.err` for errors
