mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-16 22:31:03 +02:00
feat(keyboard): ability to display and switch kb layout (#836)
This extends the existing `keys` module to be able to show the current keyboard layout, and cycle between layouts (using the `next` command) by clicking. The `keys` module has been renamed to `keyboard` to more accurately reflect its extended featureset.
This commit is contained in:
parent
ee19176a2c
commit
03e6f10141
15 changed files with 552 additions and 202 deletions
|
@ -26,7 +26,7 @@ pacman -S openssl
|
|||
pacman -S libdbusmenu-gtk3
|
||||
# for volume support
|
||||
pacman -S libpulse
|
||||
# for keys support
|
||||
# for keyboard support
|
||||
pacman -S libinput
|
||||
# for lua/cairo support
|
||||
pacman -S luajit lua51-lgi
|
||||
|
@ -42,7 +42,7 @@ apt install libssl-dev
|
|||
apt install libdbusmenu-gtk3-dev
|
||||
# for volume support
|
||||
apt install libpulse-dev
|
||||
# for keys support
|
||||
# for keyboard support
|
||||
apt install libinput-dev
|
||||
# for lua/cairo support
|
||||
apt install luajit-dev lua-lgi
|
||||
|
@ -58,7 +58,7 @@ dnf install openssl-devel
|
|||
dnf install libdbusmenu-gtk3-devel
|
||||
# for volume support
|
||||
dnf install pulseaudio-libs-devel
|
||||
# for keys support
|
||||
# for keyboard support
|
||||
dnf install libinput-devel
|
||||
# for lua/cairo support
|
||||
dnf install luajit-devel lua-lgi
|
||||
|
@ -85,7 +85,7 @@ cargo build --release --no-default-features \
|
|||
> ⚠ Make sure you enable at least one `config` feature otherwise you will not be able to start the bar!
|
||||
|
||||
| Feature | Description |
|
||||
|---------------------|-----------------------------------------------------------------------------------|
|
||||
| ------------------- | --------------------------------------------------------------------------------- |
|
||||
| **Core** | |
|
||||
| http | Enables HTTP features. Currently this includes the ability to load remote images. |
|
||||
| ipc | Enables the IPC server. |
|
||||
|
@ -101,6 +101,10 @@ cargo build --release --no-default-features \
|
|||
| clipboard | Enables the `clipboard` module. |
|
||||
| clock | Enables the `clock` module. |
|
||||
| focused | Enables the `focused` module. |
|
||||
| keyboard | Enables the `keyboard` module without keyboard layout support. |
|
||||
| keyboard+all | Enables the `keyboard` module with keyboard layout support for all compositors. |
|
||||
| keyboard+sway | Enables the `keyboard` module with keyboard layout support for Sway. |
|
||||
| keyboard+hyprland | Enables the `keyboard` module with keyboard layout support for Hyprland. |
|
||||
| launcher | Enables the `launcher` module. |
|
||||
| music+all | Enables the `music` module with support for all player types. |
|
||||
| music+mpris | Enables the `music` module with MPRIS support. |
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
- [Clock](clock)
|
||||
- [Custom](custom)
|
||||
- [Focused](focused)
|
||||
- [Keys](keys)
|
||||
- [Keyboard](keyboard)
|
||||
- [Label](label)
|
||||
- [Launcher](launcher)
|
||||
- [Music](music)
|
||||
|
|
121
docs/modules/Keyboard.md
Normal file
121
docs/modules/Keyboard.md
Normal file
|
@ -0,0 +1,121 @@
|
|||
> [!NOTE]
|
||||
> This module requires your user is in the `input` group.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> The keyboard layout feature is only available on Sway and Hyprland.
|
||||
|
||||
Displays the toggle state of the capslock, num lock and scroll lock keys, and the current keyboard layout.
|
||||
|
||||

|
||||
|
||||
## Configuration
|
||||
|
||||
> Type: `keyboard`
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
| ------------------ | ------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `show_caps` | `boolean` | `true` | Whether to show capslock indicator. |
|
||||
| `show_num` | `boolean` | `true` | Whether to show num lock indicator. |
|
||||
| `show_scroll` | `boolean` | `true` | Whether to show scroll lock indicator. |
|
||||
| `icon_size` | `integer` | `32` | Size to render icon at (image icons only). |
|
||||
| `icons.caps_on` | `string` or [image](images) | `` | Icon to show for enabled capslock indicator. |
|
||||
| `icons.caps_off` | `string` or [image](images) | `''` | Icon to show for disabled capslock indicator. |
|
||||
| `icons.num_on` | `string` or [image](images) | `` | Icon to show for enabled num lock indicator. |
|
||||
| `icons.num_off` | `string` or [image](images) | `''` | Icon to show for disabled num lock indicator. |
|
||||
| `icons.scroll_on` | `string` or [image](images) | `` | Icon to show for enabled scroll lock indicator. |
|
||||
| `icons.scroll_off` | `string` or [image](images) | `''` | Icon to show for disabled scroll lock indicator. |
|
||||
| `icons.layout_map` | `Map<string, string or image>` | `{}` | Map of icons or labels to show for a particular keyboard layout. Layouts use their actual name if not present in the map. |
|
||||
| `seat` | `string` | `seat0` | ID of the Wayland seat to attach to. |
|
||||
|
||||
<details>
|
||||
<summary>JSON</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"end": [
|
||||
{
|
||||
"type": "keyboard",
|
||||
"show_scroll": false,
|
||||
"icons": {
|
||||
"caps_on": "",
|
||||
"layout_map": {
|
||||
"English (US)": "🇺🇸",
|
||||
"Ukrainian": "🇺🇦"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>TOML</summary>
|
||||
|
||||
```toml
|
||||
[[end]]
|
||||
type = "keyboard"
|
||||
show_scroll = false
|
||||
|
||||
[end.icons]
|
||||
caps_on = ""
|
||||
|
||||
[end.icons.layout_map]
|
||||
"English (US)" = "🇺🇸"
|
||||
Ukrainian = "🇺🇦"
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>YAML</summary>
|
||||
|
||||
```yaml
|
||||
end:
|
||||
- type: keyboard
|
||||
show_scroll: false
|
||||
icons:
|
||||
caps_on:
|
||||
layout_map:
|
||||
"English (US)": 🇺🇸
|
||||
Ukrainian: 🇺🇦
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Corn</summary>
|
||||
|
||||
```corn
|
||||
{
|
||||
end = [
|
||||
{
|
||||
type = "keyboard"
|
||||
show_scroll = false
|
||||
icons.caps_on = ""
|
||||
icons.layout_map.'English (US)' = "🇺🇸"
|
||||
icons.layout_map.Ukrainian = "🇺🇦"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Styling
|
||||
|
||||
| Selector | Description |
|
||||
| -------------------------- | ------------------------------------------ |
|
||||
| `.keyboard` | Keys box container widget. |
|
||||
| `.keyboard .key` | Individual key indicator container widget. |
|
||||
| `.keyboard .key.enabled` | Key indicator where key is toggled on. |
|
||||
| `.keyboard .key.caps` | Capslock key indicator. |
|
||||
| `.keyboard .key.num` | Num lock key indicator. |
|
||||
| `.keyboard .key.scroll` | Scroll lock key indicator. |
|
||||
| `.keyboard .key.image` | Key indicator image icon. |
|
||||
| `.keyboard .key.text-icon` | Key indicator textual icon. |
|
||||
| `.keyboard .layout` | Keyboard layout indicator. |
|
||||
|
||||
For more information on styling, please see the [styling guide](styling-guide).
|
|
@ -1,102 +0,0 @@
|
|||
> [!NOTE]
|
||||
> This module requires your user is in the `input` group.
|
||||
|
||||
Displays the toggle state of the capslock, num lock and scroll lock keys.
|
||||
|
||||

|
||||
|
||||
## Configuration
|
||||
|
||||
> Type: `keys`
|
||||
|
||||
| Name | Type | Default | Description |
|
||||
|--------------------|-----------------------------|---------|--------------------------------------------------|
|
||||
| `show_caps` | `boolean` | `true` | Whether to show capslock indicator. |
|
||||
| `show_num` | `boolean` | `true` | Whether to show num lock indicator. |
|
||||
| `show_scroll` | `boolean` | `true` | Whether to show scroll lock indicator. |
|
||||
| `icon_size` | `integer` | `32` | Size to render icon at (image icons only). |
|
||||
| `icons.caps_on` | `string` or [image](images) | `` | Icon to show for enabled capslock indicator. |
|
||||
| `icons.caps_off` | `string` or [image](images) | `''` | Icon to show for disabled capslock indicator. |
|
||||
| `icons.num_on` | `string` or [image](images) | `` | Icon to show for enabled num lock indicator. |
|
||||
| `icons.num_off` | `string` or [image](images) | `''` | Icon to show for disabled num lock indicator. |
|
||||
| `icons.scroll_on` | `string` or [image](images) | `` | Icon to show for enabled scroll lock indicator. |
|
||||
| `icons.scroll_off` | `string` or [image](images) | `''` | Icon to show for disabled scroll lock indicator. |
|
||||
| `seat` | `string` | `seat0` | ID of the Wayland seat to attach to. |
|
||||
|
||||
<details>
|
||||
<summary>JSON</summary>
|
||||
|
||||
```json
|
||||
{
|
||||
"end": [
|
||||
{
|
||||
"type": "keys",
|
||||
"show_scroll": false,
|
||||
"icons": {
|
||||
"caps_on": ""
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>TOML</summary>
|
||||
|
||||
```toml
|
||||
[[end]]
|
||||
type = "keys"
|
||||
show_scroll = false
|
||||
|
||||
[end.icons]
|
||||
caps_on = ""
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>YAML</summary>
|
||||
|
||||
```yaml
|
||||
end:
|
||||
- type: keys
|
||||
show_scroll: false
|
||||
icons:
|
||||
caps_on:
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Corn</summary>
|
||||
|
||||
```corn
|
||||
{
|
||||
end = [
|
||||
{
|
||||
type = "keys"
|
||||
show_scroll = false
|
||||
icons.caps_on = ""
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Styling
|
||||
|
||||
| Selector | Description |
|
||||
|------------------------|--------------------------------------------|
|
||||
| `.keys` | Keys box container widget. |
|
||||
| `.keys .key` | Individual key indicator container widget. |
|
||||
| `.keys .key.enabled` | Key indicator where key is toggled on. |
|
||||
| `.keys .key.caps` | Capslock key indicator. |
|
||||
| `.keys .key.num` | Num lock key indicator. |
|
||||
| `.keys .key.scroll` | Scroll lock key indicator. |
|
||||
| `.keys .key.image` | Key indicator image icon. |
|
||||
| `.keys .key.text-icon` | Key indicator textual icon. |
|
||||
|
||||
For more information on styling, please see the [styling guide](styling-guide).
|
Loading…
Add table
Add a link
Reference in a new issue