Waybar
Waybar copied to clipboard
Improve keyboard response time and enable hotplug support
The keyboard-state
module used the polling mechanism to get the keyboard status by the interval.
But we more like to see the indicator update immediately, just like the pulseaudio
module.
So, I use libinput keyboard event to listen to the specific key events update when it has been triggered.
And the thread_
now is an event loop, so the interval
value has no effect.
This patch is still in progress, such as the wiki page and the man page aren't finished yet.
I will also add the keyboard removal function in this patch because libinput can get the remove event. But a prerequisite for this is all the devices that needed be listened should be connected before launching waybar, or you need to restart waybar, see related issue #1584 .
I need some opinions about this change.
Have you considered using Gio classes instead of the raw OS facilities?
E.g. Gio::FileMonitor
or Glib event loop?
Have you considered using Gio classes instead of the raw OS facilities? E.g.
Gio::FileMonitor
or Glib event loop?
I have tried the sample code below listening to the /dev/input
: https://gist.github.com/simu/0ed1e9b12871e20cec48efe73eeeb8e1
The result is as follows:
monitoring /dev/input
/dev/input/event3 contents changed
/dev/input/event7 contents changed
/dev/input/event14 contents changed
/dev/input/event13 contents changed
/dev/input/event1 contents changed
/dev/input/event2 contents changed
/dev/input/event4 contents changed
/dev/input/event3 contents changed
/dev/input/event7 set of changes done
/dev/input/event14 set of changes done
/dev/input/event13 set of changes done
/dev/input/event1 set of changes done
/dev/input/event2 set of changes done
/dev/input/event4 set of changes done
/dev/input/event3 set of changes done
/dev/input/event3 contents changed
/dev/input/event7 contents changed
/dev/input/event14 contents changed
/dev/input/event13 contents changed
/dev/input/event1 contents changed
/dev/input/event2 contents changed
/dev/input/event4 contents changed
/dev/input/event3 contents changed
/dev/input/event7 contents changed
/dev/input/event14 contents changed
/dev/input/event13 contents changed
/dev/input/event1 contents changed
/dev/input/event2 contents changed
/dev/input/event4 contents changed
/dev/input/event3 contents changed
/dev/input/event7 contents changed
/dev/input/event14 contents changed
/dev/input/event13 contents changed
Even if I don't add or delete any device, it will get the unneeded events because the G_FILE_MONITOR_WATCH_MOVE
attribute will lead to recording various events.
The current version has hotplug support and event-based keyboard lock status detection, problems in the first comment have been resolved. It can auto-detect new devices and won't crash when keyboards have been removed.
Thx! Can you also add the deprecated interval info into the github wiki?