Skip to content

Br1ght0ne/swaylayout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Get the current Sway keyboard layout

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published