Skip to content

feat(widget): add lock keys indicator - #1077

Open
iremsu-umit35 wants to merge 1 commit into
amnweb:mainfrom
iremsu-umit35:feat/lock-key-indicators
Open

feat(widget): add lock keys indicator#1077
iremsu-umit35 wants to merge 1 commit into
amnweb:mainfrom
iremsu-umit35:feat/lock-key-indicators

Conversation

@iremsu-umit35

Copy link
Copy Markdown

Summary

Adds a new Lock Keys widget for displaying the current Caps Lock and Num Lock states in the YASB bar.

Closes #1023

The widget:

  • displays configurable Caps Lock and Num Lock state labels
  • updates automatically when the keyboard lock state changes
  • supports primary and alternate labels
  • provides state-specific CSS classes for styling
  • includes configuration documentation

Testing

Tested locally on Windows with YASB.

  • Verified Caps Lock ON/OFF state updates
  • Verified Num Lock ON/OFF state updates
  • Verified both states update correctly together
  • Verified alternate label toggle
  • ruff check . passes
  • ruff format --check . passes
  • pre-commit checks pass

AI usage

AI tools were used as an assistive aid during implementation. The resulting changes were manually reviewed, tested locally, and validated with the project's linting and formatting tools.

@amnweb

amnweb commented Aug 24, 2026

Copy link
Copy Markdown
Owner

You can use a custom widget for that. Why do you need a separate widget for a simple job?

@iremsu-umit35

Copy link
Copy Markdown
Author

Thanks for the feedback. I went with a separate widget because I wanted the lock states to be read directly from Windows and update automatically without requiring users to configure an external command. I also thought having configurable state labels and state-specific CSS classes would make it easier to use and style.

That said, if you prefer this to be implemented through the existing CustomWidget instead, I'm happy to rework it that way.

@amnweb

amnweb commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Main issue for me is the timer. 200ms is 5 polls a second, and widgets are built per bar, so on a 3 monitor setup that's 3 timers doing the same two GetKeyState calls forever. The 50ms lower bound makes it worse.

Maybe we can use our own hotkey listener for this instead of polling, we already have one in core/utils/win32/hotkeys.py. Worth looking into.

Also whatever it ends up being, it should be shared between bars instead of one instance per widget, see how CpuWidget keeps CpuWorker as a class attribute.

And when I say a custom widget can do the same job, I mean you can set up a custom widget to call a PowerShell command every second and give you the same result you have now with the new widget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Digital indicator for caps lock, num lock

2 participants