rszyma / kanata-tray

Tray Icon for Kanata
GNU General Public License v3.0
33 stars 1 forks source link

Support for mac #16

Closed guruor closed 2 months ago

guruor commented 3 months ago

I was looking for system tray for mac os and found this comment: https://github.com/jtroo/kanata/issues/29#issuecomment-1936327313, I gave it a try and I was able to successfully build the app on my M1 Mac after adding sys_proc_attr_darwin.go in os_specific directory:

package os_specific

import "syscall"

var ProcessAttr *syscall.SysProcAttr = &syscall.SysProcAttr{}

@rszyma You can call the app cross-platform, thanks for the app.


I did not find a discussion so creating this issue so people can find the instructions to setup.

Build instructions

# Make sure your system golang version matches the project version
git clone https://github.com/rszyma/kanata-tray /tmp/kanata-tray
cd /tmp/kanata-tray
GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 GO111MODULE=on go build -ldflags "-s -w -X 'main.buildVersion=latest' -X 'main.buildHash=$(git rev-parse HEAD)' -X 'main.buildDate=$(date -u)'" -trimpath -o dist/kanata-tray
cp ./dist/kanata-tray ~/.local/bin

Default config was read from $HOME/Library/Application\ Support/kanata-tray/kanata-tray.toml path, my working config:

'$schema' = 'https://raw.githubusercontent.com/rszyma/kanata-tray/main/doc/config_schema.json'

[general]
allow_concurrent_presets = false

[defaults]
kanata_executable = '' # if empty or omitted, system $PATH will be searched.
kanata_config = ''     # if empty or not omitted, kanata default config locations will be used.
tcp_port = 5829        # if not specified, defaults to 5829

[defaults.layer_icons]
# mouse = 'mouse.png'
# qwerty = 'qwerty.ico'
# '*' = 'other_layers.ico'

[presets.'main cfg']
kanata_config = '~/.config/kanata/kanata.kbd'
autorun = true
# kanata_executable = ''
# layer_icons = {  }
# tcp_port = 1234

NOTE: Since kanata requires sudo permission to run the app, you'll need to run kanata-tray also with sudo.

Sample screenshot: Screenshot 2024-04-15 at 4 05 02 PM