jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
3.08k stars 129 forks source link

Bug: No keys are sending on Mac #1317

Open CampAsAChamp opened 3 weeks ago

CampAsAChamp commented 3 weeks ago

Requirements

Describe the bug

Keys are not being sent, but are being seen/heard by Kanata

Relevant kanata config

Using the minimal.kbd

(defcfg
  process-unmapped-keys yes
)

(defsrc
  caps grv         i
              j    k    l
  lsft rsft
)

(deflayer default
  @cap @grv        _ 
              _    _    _ 
  _    _   
)

(deflayer arrows
  _    _           up 
              left down rght 
  _    _   
)

(defalias
  cap (tap-hold-press 200 200 caps lctl)
  grv (tap-hold-press 200 200 grv (layer-toggle arrows))
)

To Reproduce

  1. Run kanata with minimal.kbd (with sudo)
  2. Press back tick
  3. See the keys being picked up in the terminal
  4. Key presses not being seen in the text editor (back tick, or arrows moving the cursor)

Video:

https://github.com/user-attachments/assets/a8f081fe-e79f-42b4-bb2c-d223537c1d4f

Expected behavior

Keys would be sent. Pressing any other keys (A-Z) with process-unmapped-keys yes I expected them to also send, but I got neither.

Kanata version

kanata 1.70

Debug logs

No response

Operating system

MacOS 14.7

Additional context

No response

jtroo commented 3 weeks ago

Maybe this can help: https://github.com/jtroo/kanata/issues/1211

andreicorpo commented 3 weeks ago

I am also encoutering this issue. https://github.com/jtroo/kanata/issues/1211 doesn't seem to help with this.

CampAsAChamp commented 3 weeks ago

I'll give #1211 a try and also get some more debug logs to see where it might be going wrong

EDIT: Already had both Kanata and iTerm in the input monitoring, so don't think it's that.

EDIT 2: I do see this PR for the driverkit to bump it to version 5.0.0, which is what I have when I run the below command. So hoping that is just my issue and when that gets merged this hopefully will resolve

defaults read /Applications/.Karabiner-VirtualHIDDevice-Manager.app/Contents/Info.plist CFBundleVersion
> 5.0.0
tissak commented 3 weeks ago

Confirming the last comment by @CampAsAChamp. I had this issue on MacOS 15.0.1 of key presses being detected but not being written. I repointed my local cargo.toml to the driverkit git repo mentioned in PR and rebuilt locally. Now works.

CampAsAChamp commented 3 weeks ago

@jtroo how should I resolve this? Close it and mention that this issue should be fixed when that above PR gets merged? Or how would you like?

The only reason why I have version 5.0.0 is because that's what Karabiner is shipping with currently.

jtroo commented 3 weeks ago

We can leave this open until we bump the dependency version in Kanata.

fearlessgeekmedia commented 3 weeks ago

I'm having trouble even with 5.0.0. On MacOS Sonoma 14.7. When I run kanata, my whole keyboard is unusable.

jtroo commented 3 weeks ago

@fearlessgeekmedia my understanding is that, having 5.0.0 is the problem (on kanata side) and kanata needs an updated dependency to work correctly.

fearlessgeekmedia commented 3 weeks ago

Oh, ok. So I just need to wait?

jtroo commented 3 weeks ago

You could:

mattdw commented 3 weeks ago

Here's my build with updated driverkit dependency - it worked for me on 15.1, M1 Apple Silicon. (With the 5.0.0 Karabiner driver .pkg installed.)

https://www.dropbox.com/scl/fi/4bsz4a2qih35ui9gp1fhe/kanata_w_kdk_5.0.0.zip?rlkey=g6139xiug7zcr1b9ccie15xwd&dl=0

Took me a while to figure out I also needed to run the Karabiner daemon separately, e.g.

# in one tab
sudo '/Library/Application Support/org.pqrs/Karabiner-DriverKit-VirtualHIDDevice/Applications/Karabiner-VirtualHIDDevice-Daemon.app/Contents/MacOS/Karabiner-VirtualHIDDevice-Daemon'

# in another tab
sudo ./kanata --cfg ~/.config/kanata.kb
fearlessgeekmedia commented 3 weeks ago

I tried an older Karabiner driver and compiled Kanata myself already. Neither of those solved my problem. I ended up using claude.ai to convert my Kanata config to a Karabiner Elements mod. It works. :)

On Tue, Nov 5, 2024, 1:15 AM Matt Wilson @.***> wrote:

Here's my build with updated driverkit dependenciy - it worked for me on 15.1, M1 Apple Silicon.

https://www.dropbox.com/scl/fi/4bsz4a2qih35ui9gp1fhe/kanata_w_kdk_5.0.0.zip?rlkey=g6139xiug7zcr1b9ccie15xwd&dl=0

Took me a while to figure out I also needed to run the Karabiner daemon separately, e.g.

in one tab

sudo '/Library/Application Support/org.pqrs/Karabiner-DriverKit-VirtualHIDDevice/Applications/Karabiner-VirtualHIDDevice-Daemon.app/Contents/MacOS/Karabiner-VirtualHIDDevice-Daemon'

in another tab

sudo ./kanata --cfg ~/.config/kanata.kb

β€” Reply to this email directly, view it on GitHub https://github.com/jtroo/kanata/issues/1317#issuecomment-2456506215, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HGA5VEYY4MZAKMVKVEVP3Z7B5C5AVCNFSM6AAAAABQ7W2HBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINJWGUYDMMRRGU . You are receiving this because you were mentioned.Message ID: @.***>

jcger commented 2 weeks ago

We can leave this open until we bump the dependency version in Kanata.

When do you expect this to happen?

fearlessgeekmedia commented 2 weeks ago

I didn't specify earlier. I'm using one of the Intel Macs.

jtroo commented 2 weeks ago

We can leave this open until we bump the dependency version in Kanata.

When do you expect this to happen?

You're asking for a time estimate from a free, donations-not-accepted, open source project πŸ˜‚. Within [0, ∞) seconds.

jcger commented 2 weeks ago

We can leave this open until we bump the dependency version in Kanata.

When do you expect this to happen?

You're asking for a time estimate from a free, donations-not-accepted, open source project πŸ˜‚. Within [0, ∞) seconds.

Sorry, my intention wasn't to create any pressure or push. Just wanted to check if this is something you're planning to implement soon, so I can wait for it, or if not, I will try to do so locally. My bad for not taking enough time to write this properly πŸ™

jtroo commented 2 weeks ago

There's not much work to do in the Kanata repo. The blocker is having the updated dependency consumable via crates.io for use with cargo install. I'm not sure how active @psych3r is so it might be a while to get the pr merged and crate published. It may be desirable to: have a new maintainer for the dependency or vendor and maintain the dependency within the Kanata repo.

psych3r commented 2 weeks ago

I've been quite busy for the last month. I'll work on merging the PR and uploading a new version of the crate by this weekend if not sooner.

newsve commented 1 week ago

I must have missed something but I couldn't get it to work. I git pulled and cargo build the latest kanata, installed Karabiner-DriverKit-VirtualHIDDevice-5.0.0.pkg, activated latter and still have given Terminal permission for Input Monitoring. But it is still not working, before my installation worked.

Edit: I get continuous connect_failed asio.system:2 I am on macOS 14.6.1 (updating now, maybe it is related...)

fearlessgeekmedia commented 1 week ago

I don't think you missed anything. We're essentially waiting.Or you could do what I did and use Karabiner Elements.

On Tue, Nov 12, 2024, 12:33 PM newsve @.***> wrote:

I must have missed something but I couldn't get it to work. I git pulled and cargo build the latest kanata, installed Karabiner-DriverKit-VirtualHIDDevice-5.0.0.pkg, activated latter and still have given Terminal permission for Input Monitoring. But it is still not working, before my installation worked.

β€” Reply to this email directly, view it on GitHub https://github.com/jtroo/kanata/issues/1317#issuecomment-2471400115, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HGA5WSOJZVNA5HX5ZKLPL2AJJXZAVCNFSM6AAAAABQ7W2HBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZRGQYDAMJRGU . You are receiving this because you were mentioned.Message ID: @.***>

Lawrence-of-AnKing commented 1 week ago

While I run kanata, my keyboard and mouse not work anymore, I can only exit by Ctrl + Space + Esc. I tried Karabiner-VirtualHIDDevice-Manager 3.1 and 5.0, nothing changed. I do real not want turn back to karabiner, the terrible config...

fearlessgeekmedia commented 1 week ago

Yeah, pretty much what was happening to me too. Granted I am only using it for keyboard shortcuts and not anything with the mouse. So I didn't have the mouse issues.

On Tue, Nov 12, 2024 at 7:59β€―PM Lawrence Liu @.***> wrote:

While I run kanata, my keyboard and mouse not work anymore, I can only exit by Ctrl + Space + Esc. I tried Karabiner-VirtualHIDDevice-Manager 3.1 and 5.0, nothing changed. I do real not want turn back to karabiner, the terrible config...

β€” Reply to this email directly, view it on GitHub https://github.com/jtroo/kanata/issues/1317#issuecomment-2472268142, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3HGA5QF74V2EGARDCD36KL2AK6BZAVCNFSM6AAAAABQ7W2HBGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZSGI3DQMJUGI . You are receiving this because you were mentioned.Message ID: @.***>

jtroo commented 1 week ago

If you're compiling the latest main then the assumption is it should work now. The dependency bump was merged. But something else might be broken; perhaps something specific to intel mac

newsve commented 1 week ago

While I run kanata, my keyboard and mouse not work anymore, I can only exit by Ctrl + Space + Esc.

I have exactly the same paired with this contiunous connect_failed asio.system:2

perhaps something specific to intel mac

I am running it on a Silicon Mac (M2). My config again:

Please let me know if I can do/test anything more in order to help to find the cause.

newsve commented 1 week ago

Sorry for spamming this thread but I found the issue. Contrary to the past versions, we need now to run that Karabiner daemon as well, another user gave that hint in https://github.com/jtroo/kanata/issues/1317#issuecomment-2456506215

So, all works fine now with the config I gave in the last comment.

santhosh2011 commented 1 week ago

running the daemon in a seperate window works but should we keep one terminal always running for it?

santhosh2011 commented 1 week ago

Is this fixed? or should we still keep running the daemon in another terminal?

jtroo commented 1 week ago

Is this fixed? or should we still keep running the daemon in another terminal?

Is this something broken that needs to be "fixed" in the first place? I would guess running the daemon is the intended use case for working with the new karabiner. Seems there might be some improvements here though.

psych3r commented 1 week ago

I believe we need to update the docs. Karabiner-DriverKit Updated their usage instructions. While it used to be enough to activate the driver, now users should run the daemon as well. Activating the driver is mentioned in Kanata's docs, we should add running the daemon as well. I believe it won't be hard to figure out a way to have the daemon run automatically instead of running it manually. Maybe using macOS's launch agents or launch daemons, I am not that familiar with them tbh. So if someone can share a way to do this, that would be awesome! Then we'll just need to update the docs with how to automatically run the daemon.

Lawrence-of-AnKing commented 1 week ago

Is there a hero write a applescript to run all of them? I try to run kanata by applescript, faild.

newsve commented 1 week ago

start up the daemon

This options would be actually pretty nice and would remove some friction in the UX.

Edit: Or display an error if the daemon isn't installed.

thomastthai commented 6 days ago

I experienced the issue with the keyboard not working when using the Kanata v1.7.0 release. I can confirm the fix:

newsve commented 2 days ago

I asked ChatGPT to write a shell script kanata.sh (advantage is that you have to run and terminate only one thing):

#!/bin/zsh

# Quick help/full install process:
#   - Install Rust from rustup.rs 
#   - `git clone https://github.com/jtroo/kanata.git` in home (`~/`), then `cd kanata` and `cargo build`
#   - Install https://github.com/pqrs-org/Karabiner-DriverKit-VirtualHIDDevice version: ^5.0.0
#   - Allow Input Monitoring for latter somewhere in macOS' settings
#   - `chmod +x kanata.sh` this file after creation!

# Checking if a parameter was provided
if [ "$#" -ne 1 ]; then
    echo "Usage: $0 <path_to_kbd_file>"
    exit 1
fi

# Activate Karabiner-VirtualHIDDevice-Manager (actually needs to be done only once but yeah)
sudo /Applications/.Karabiner-VirtualHIDDevice-Manager.app/Contents/MacOS/Karabiner-VirtualHIDDevice-Manager activate

# Run Karabiner-VirtualHIDDevice-Daemon
sudo '/Library/Application Support/org.pqrs/Karabiner-DriverKit-VirtualHIDDevice/Applications/Karabiner-VirtualHIDDevice-Daemon.app/Contents/MacOS/Karabiner-VirtualHIDDevice-Daemon' &

# Execute kanata with the provided parameter
sudo ~/kanata/target/debug/kanata -nc "$1"

Then, once...

chmod +x kanata.sh

...and execute with...

./kanata.sh <path_to_kbd_file>

Edit: Check ofc if your kanata install folder is the same as in the script! It is just the one when you do a git clone of the kanata repo in your home folder ~.

Edit2, Alternative: You could also just cram the last two lines into one, have a hard-coded kbd-file and run that super long line every time (and since in the shell history you can easily access it with the arrow up or ctrl-r too, actually not much worse solution but this script is a bit cleaner and in case the history is not accessible nor available also much easier to remember).