Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is keyboard-state compatible with ZMK powered keyboards? #3796

Open
Kylar514 opened this issue Nov 28, 2024 · 3 comments
Open

Is keyboard-state compatible with ZMK powered keyboards? #3796

Kylar514 opened this issue Nov 28, 2024 · 3 comments
Labels
bug Something isn't working inhibitor keyboard

Comments

@Kylar514
Copy link

Kylar514 commented Nov 28, 2024

I am running the latest waybar. I have the following in my config.

"keyboard-state": {
  "device-path": "/dev/input/event8",
	//"numlock": true,
	"capslock": true,
	"format": {
		"numlock": "N {icon}",
		"capslock": "󰪛 {icon}",
	},
  "format-icons": {
      "locked": "",
      "unlocked": ""
    },
  },

Event8 is active, and i can run a evtest and see when capslock is pressed. Its just waybar says it can't find a device at event8. I can change this to event3, and it detects and reads my MX Masters 3 mouse, I can also plug in any other keyboard and it properly reads the caps lock in the waybar.

I think its a compatibility issue? idk.

I did add my user to the group. So it shouldnt be a permissions issue, especially since waybar can accurately detect other devices.

event8 is the zmk keyboard on this boot, it changes everyboot, that device-path line was just added for debugging purposes.

@github-actions github-actions bot added bug Something isn't working inhibitor keyboard labels Nov 28, 2024
@duu261
Copy link

duu261 commented Jan 14, 2025

have you solved this?
ive the same problem with my split zmk too

@Kylar514
Copy link
Author

Kylar514 commented Jan 14, 2025

I wrote a script and made it a custom module.

script

#!/bin/bash

caps_lock_state=false
state_file=/tmp/caps_lock_state.txt

evtest /dev/input/by-id/usb-ZMK_Project_Cyboard_64473BEE7CA8FBD7-event-kbd | while read -r line; do
    if echo "$line" | grep -q "EV_KEY.*KEY_CAPSLOCK"; then
        if echo "$line" | grep -q "value 1"; then
            if $caps_lock_state; then
                caps_lock_state=false
                echo "" > "$state_file"
                notify-send "Caps Lock OFF"
            else
                caps_lock_state=true
                echo "󰪛" > "$state_file"
                notify-send "Caps Lock ON"
            fi
        fi
    fi
done

Then I made use of this custom module.

  "custom/capslock": {
    "exec": "cat /tmp/caps_lock_state.txt",
    "format": "<span color=\"#f53c3c\">{}</span>",
    "interval": 1
  },

It's pretty self-explanatory, but the script assumes that the caps lock is off at the computer's start. Whenever the caps lock is pressed, it changes the contents of a temp file, which is displayed in the swaybar. The file gets deleted on every boot.

edit: I would imagine the name of your zmk keyboard will be different from mine, so you would need to change that. You will likely find it in /dev/input/by-id/

@xuhdev
Copy link

xuhdev commented Mar 6, 2025

I have a zmk keyboard and keyboard-state works out of box for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working inhibitor keyboard
Projects
None yet
Development

No branches or pull requests

3 participants