Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the xkb-switch keyboard layout reader. (greshake#1386)
* Add support for the xkb-switch keyboard layout reader. Closes greshake#1384 at greshake#1384 If you set the xkbmap layout to a multilingual string with variants, such as: ``` setxkbmap -layout us,es,ru setxkbmap -variant dvorak,,phonetic ``` the `keyboard_layout` block will not show the current layout nor the current variant. It will only show the entire multilingual layout string. This is because `i3status-rust` uses the command [`setxkbmap -query`](https://github.com/greshake/i3status-rust/blob/b6e1b0b755de9f4520f1ecf17086d62fc5f190fe/src/blocks/keyboard_layout.rs#L63) to get the current layout. ``` $ setxkbmap -query ☸ 0007-04 rules: evdev model: pc105 layout: us,es,ru variant: dvorak,,phonetic options: grp:ctrls_toggle ``` This commit uses [`xkb-switch`](https://github.com/grwlf/xkb-switch) to read the current layout and keyboard variant. Example usage: ``` [[block]] block = "keyboard_layout" driver = "xkbswitch" format = "{layout} {variant}" interval = 1 ``` * Fix formatting and linter errors. - Less newlines. - Use unwrap_or_else instead of running unwrap_or with a function call. This improves efficiency by making the function call lazy. - Use a character instead of a single-character string for split(). * Add documentation
- Loading branch information