Skip to content

Latest commit

 

History

History
79 lines (62 loc) · 1.68 KB

File metadata and controls

79 lines (62 loc) · 1.68 KB

swaylayout

Get the current Sway keyboard layout

Table of contents

Installation

For now:

cargo install --git https://github.com/filalex77/swaylayout

Prerequisites

Get the identifier of your keyboard, e.g.

$ swaymsg -t get_inputs
# ...
Input device: AT Translated Set 2 keyboard
  Type: Keyboard
  Identifier: 1:1:AT_Translated_Set_2_keyboard
  Product ID: 1
  Vendor ID: 1
  Active Keyboard Layout: English (US)
  Libinput Send Events: enabled

# here it's 1:1:AT_Translated_Set_2_keyboard

Usage

Just get the current layout:

$ swaylayout <ID>
English (US)

Listen to layout changes and output new layout on every change:

$ swaylayout --listen <ID>

Plugging that into waybar .config/waybar/config:

{
    "modules-right": [
        "custom/keyboard"
    ],
    "custom/keyboard": {
        "exec": "swaylayout --listen <ID>"
    }
}

Raison d’être

This unscientific benchmark:

CommandMean [ms]Min [ms]Max [ms]Relative
swaylayout0.5 ± 0.20.41.71.00
pipe swaymsg into jq28.8 ± 2.126.635.952.85 ± 15.14

e.g. 36-68x times faster than the naive solution

Contributing

Unlikely, but appreciated.

License

MIT, because who cares.