Get the current Sway keyboard layout
[[#license][License]]
Installation For now:
cargo install --git https://github.com/filalex77/swaylayout
$ swaymsg -t get_inputs
Input device: AT Translated Set 2 keyboard Type: Keyboard Identifier: 1:1:ATTranslatedSet2keyboard Product ID: 1 Vendor ID: 1 Active Keyboard Layout: English (US) Libinput Send Events: enabled
$ swaylayout
Listen to layout changes and output new layout on every change:
$ swaylayout --listen
Plugging that into waybar =.config/waybar/config=:
{
"modules-right": [
"custom/keyboard"
],
"custom/keyboard": {
"exec": "swaylayout --listen
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative | |--------------------------+------------+----------+----------+---------------| | =swaylayout= | 0.5 ± 0.2 | 0.4 | 1.7 | 1.00 | | pipe =swaymsg= into =jq= | 28.8 ± 2.1 | 26.6 | 35.9 | 52.85 ± 15.14 |
e.g. 36-68x times faster than the naive solution
Contributing Unlikely, but appreciated.
License MIT, because who cares.