Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

riodelphino/macime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

macime

A blazing faster IME switching tool for macOS. (Swift / launchd service)

Story

I've used macism and im-select before.
But on my older Macs, these tools always required a short wait to switch IME modes. It was an unacceptable delay for daily use.

macime significantly reduces this delay by 30% to 70%. (Depends on usage.)

Though it still has a slight delay, but I’m very satisfied with the switching speed since v3.x.

If you’re a Mac user frustrated by slow IME switching, give it a try.

Why it’s fast

  1. Sets and gets the IME in a single operation
  2. Uses a launchd service
  3. Written in native Swift
  4. Optimized code

Feature

  • Get current IME
  • Set a specified IME
  • Save current IME
  • Load(Restore) the previous IME
  • Switch IME while saving the previous one (in single step)
  • List all IMEs
  • Output results in plain text or JSON string
  • Faster switching by macimed launchd service

Requirements

  • macOS

Install

brew tap riodelphino/tap
brew install macime

Uninstall

brew uninstall macime

Upgrade

brew update
brew upgrade macime

If launchd service is enabled, ensure to restart it:

brew services restart macime

Register as a launchd Service

Optional, but STRONGLY RECOMMENDED !!.
30% faster than running macimed directly. (e.g. 128ms -> 89ms)

# Start macimed service
brew services start macime

# Stop macimed service
brew services stop macime

# Manually start (for test, can see the log)
macimed

Usage

macime

Show macime version:

macime --version

Show macime help:

macime --help

Sub commands:

macime get [options]
macime set <IME_ID> [options]
macime list [options]
macime save [options]
macime load [options]

get Show the current IME.

set Switch to the specified IME. Optionally saves the previous IME.

list List available IMEs.

save Save current IME.

load Restore the previous IME.

Get current IME

macime get
# com.apple.keylayout.ABC

macime get --detail
# id: com.apple.keylayout.ABC
# localizedName: ABC
# isSelectCapable: true
# isSelected: true
# sourceLanguages: ["en", "af", ... "zu"]

macime get --detail --json
# {"isSelectCapable":true,"isSelected":true,"sourceLanguages":["en","af", ... ,"zu"],"localizedName":"ABC","id":"com.apple.keylayout.ABC"}

Set IME

# Set IME
macime set com.apple.keylayout.ABC

# Set IME while saving current IME as `DEFAULT`
macime set com.apple.keylayout.ABC --save
# The IME ID is saved at `/tmp/riodelphino.macime/prev/DEFAULT`

# Set IME while saving current IME as <session_id>
macime set com.apple.keylayout.ABC --save --session-id nvim-1001
# The IME ID is saved at `/tmp/riodelphino.macime/prev/nvim-1001`

Note

Using set and --save together reduces elapsed time 50%. While other tools need two excution like <command_name> -> <command_name> set com.apple.keylayout.ABC

Save IME

# Save current IME to `DEFAULT`
macime save
# Current IME ID is set to `/tmp/riodelphino.macime/prev/DEFAULT`

# Save current IME to `<session_id>`
macime save --session-id nvim-1001
# Current IME ID is set to `/tmp/riodelphino.macime/prev/nvim-1001`

Load IME

# Load IME from `DEFAULT`
macime load
# Reads previous IME ID from `/tmp/riodelphino.macime/prev/DEFAULT`, then set it.

# Load IME from `<session_id>`
macime load --session-id nvim-1001
# Reads previous IME ID from `/tmp/riodelphino.macime/prev/nvim-1001`, then set it.

List IME

macime list # id list
macime list --detail # detailed list
macime list --json # json list
macime list --select-capable # show only selectable IME methods
# --detail, --json and --select-capable can be mixtured

macimed

macimed is bundled with macime and can be managed by launchd via:

brew services start macime
# Although the service name is `macime`, `macimed` is executed internally.

When run as a launchd service, execution time is reduced by about 30% compared to running macimed directly.

You can also start macimed manually to monitor logs and observe its behavior, though this is slower.

macimed Log

macimed leaves log.
The log location depends on whether it is run directly or via launchd, and on the environment.

Log:

  • /tmp/riodelphino.macimed.log
  • /usr/local/var/log/riodelphino.macimed.log
  • /opt/homebrew/var/log/riodelphino.macimed.log (Apple Silicon)

Error:

  • /tmp/riodelphino.macimed.err
  • /usr/local/var/log/riodelphino.macimed.err
  • /opt/homebrew/var/log/riodelphino.macimed.err (Apple Silicon)

Integration

Neovim

(Recommended) Install wrapper plugin: riodelphino/macime.nvim

For more details, see doc/integration.md.

Stored in Temporary dir

The previous IME ID is stored in:

When directly executing macimed:

  • /tmp/riodelphino.macime/<session_id>

With brew services start:

  • /private/tmp/riodelphino.macime/<session_id>

These files are deleted when you shutdown macOS.

Tips

For faster switching with low latency, set this config in init.lua:

vim.o.timeoutlen = 0 -- 0 ~ 50

Warning

This config affects other keybinds in nvim.

Issues

azookey prevents macime to change IME

azookey | azookey-Desktop prevents macime set command to work. I guess it's because they are still alpha version.

Solutions for now:

  • Uninstal azookey

Contribution

Contributions are welcome:

# Clone
git clone https://github.com/riodelphino/macime
cd macime

# Build for debug
swift build
# Build for release
swift build -c release

Others

Deprecated: $MACIME_TEMP_DIR environmental value

Changelog

See CHANGELOG

License

MIT License. See LICENSE

Refers

Related

About

A swift-based faster IME switcher for macOS.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages