Skip to content

Commit 67426bd

Browse files
authored
Merge pull request #783 from JakeStanger/feat/libinput
feat: libinput `keys` module
2 parents 353ee92 + ccfe73f commit 67426bd

File tree

20 files changed

+798
-106
lines changed

20 files changed

+798
-106
lines changed

Diff for: .github/scripts/ubuntu_setup.sh

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ $SUDO apt-get update && $SUDO apt-get install --assume-yes \
1717
libssl-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
1818
libgtk-3-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
1919
libgtk-layer-shell-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
20+
libinput-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
2021
libdbusmenu-gtk3-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
2122
libpulse-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
2223
libluajit-5.1-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH}

Diff for: Cargo.lock

+71-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Cargo.toml

+10-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ default = [
1818
"focused",
1919
"http",
2020
"ipc",
21+
"keys",
2122
"launcher",
2223
"music+all",
2324
"network_manager",
@@ -49,12 +50,14 @@ http = ["dep:reqwest"]
4950

5051
cairo = ["lua-src", "mlua", "cairo-rs"]
5152

52-
clipboard = ["nix"]
53+
clipboard = ["dep:nix"]
5354

5455
clock = ["chrono"]
5556

5657
focused = []
5758

59+
keys = ["dep:input", "dep:evdev-rs", "dep:libc", "dep:nix"]
60+
5861
launcher = []
5962

6063
music = ["regex"]
@@ -131,12 +134,14 @@ lua-src = { version = "547.0.0", optional = true }
131134
mlua = { version = "0.9.9", optional = true, features = ["luajit"] }
132135
cairo-rs = { version = "0.18.5", optional = true, features = ["png"] }
133136

134-
# clipboard
135-
nix = { version = "0.29.0", optional = true, features = ["event", "fs"] }
136-
137137
# clock
138138
chrono = { version = "0.4.39", optional = true, default-features = false, features = ["clock", "unstable-locales"] }
139139

140+
# keys
141+
input = { version = "0.9.1", optional = true }
142+
evdev-rs = { version = "0.6.1", optional = true }
143+
libc = { version = "0.2.164", optional = true }
144+
140145
# music
141146
mpd-utils = { version = "0.2.1", optional = true }
142147
mpris = { version = "2.0.1", optional = true }
@@ -163,6 +168,7 @@ futures-util = { version = "0.3.31", optional = true }
163168

164169
# shared
165170
futures-lite = { version = "2.5.0", optional = true } # network_manager, upower, workspaces
171+
nix = { version = "0.29.0", optional = true, features = ["event", "fs", "poll"] } # clipboard, input
166172
regex = { version = "1.11.1", default-features = false, features = [
167173
"std",
168174
], optional = true } # music, sys_info

Diff for: docs/Compiling.md

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pacman -S openssl
2626
pacman -S libdbusmenu-gtk3
2727
# for volume support
2828
pacman -S libpulse
29+
# for keys support
30+
pacman -S libinput
2931
# for lua/cairo support
3032
pacman -S luajit lua51-lgi
3133
```
@@ -40,6 +42,8 @@ apt install libssl-dev
4042
apt install libdbusmenu-gtk3-dev
4143
# for volume support
4244
apt install libpulse-dev
45+
# for keys support
46+
apt install libinput-dev
4347
# for lua/cairo support
4448
apt install luajit-dev lua-lgi
4549
```
@@ -54,6 +58,8 @@ dnf install openssl-devel
5458
dnf install libdbusmenu-gtk3-devel
5559
# for volume support
5660
dnf install pulseaudio-libs-devel
61+
# for keys support
62+
dnf install libinput-devel
5763
# for lua/cairo support
5864
dnf install luajit-devel lua-lgi
5965
```

Diff for: docs/modules/Keys.md

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
> [!NOTE]
2+
> This module requires your user is in the `input` group.
3+
4+
Displays the toggle state of the capslock, num lock and scroll lock keys.
5+
6+
![Screenshot of clock widget with popup open](https://f.jstanger.dev/github/ironbar/keys.png)
7+
8+
## Configuration
9+
10+
> Type: `keys`
11+
12+
| Name | Type | Default | Description |
13+
|--------------------|-----------------------------|---------|--------------------------------------------------|
14+
| `show_caps` | `boolean` | `true` | Whether to show capslock indicator. |
15+
| `show_num` | `boolean` | `true` | Whether to show num lock indicator. |
16+
| `show_scroll` | `boolean` | `true` | Whether to show scroll lock indicator. |
17+
| `icon_size` | `integer` | `32` | Size to render icon at (image icons only). |
18+
| `icons.caps_on` | `string` or [image](images) | `󰪛` | Icon to show for enabled capslock indicator. |
19+
| `icons.caps_off` | `string` or [image](images) | `''` | Icon to show for disabled capslock indicator. |
20+
| `icons.num_on` | `string` or [image](images) | `` | Icon to show for enabled num lock indicator. |
21+
| `icons.num_off` | `string` or [image](images) | `''` | Icon to show for disabled num lock indicator. |
22+
| `icons.scroll_on` | `string` or [image](images) | `` | Icon to show for enabled scroll lock indicator. |
23+
| `icons.scroll_off` | `string` or [image](images) | `''` | Icon to show for disabled scroll lock indicator. |
24+
| `seat` | `string` | `seat0` | ID of the Wayland seat to attach to. |
25+
26+
<details>
27+
<summary>JSON</summary>
28+
29+
```json
30+
{
31+
"end": [
32+
{
33+
"type": "keys",
34+
"show_scroll": false,
35+
"icons": {
36+
"caps_on": "󰪛"
37+
}
38+
}
39+
]
40+
}
41+
```
42+
43+
</details>
44+
45+
<details>
46+
<summary>TOML</summary>
47+
48+
```toml
49+
[[end]]
50+
type = "keys"
51+
show_scroll = false
52+
53+
[end.icons]
54+
caps_on = "󰪛"
55+
```
56+
57+
</details>
58+
59+
<details>
60+
<summary>YAML</summary>
61+
62+
```yaml
63+
end:
64+
- type: keys
65+
show_scroll: false
66+
icons:
67+
caps_on: 󰪛
68+
```
69+
70+
</details>
71+
72+
<details>
73+
<summary>Corn</summary>
74+
75+
```corn
76+
{
77+
end = [
78+
{
79+
type = "keys"
80+
show_scroll = false
81+
icons.caps_on = "󰪛"
82+
}
83+
]
84+
}
85+
```
86+
87+
</details>
88+
89+
## Styling
90+
91+
| Selector | Description |
92+
|------------------------|--------------------------------------------|
93+
| `.keys` | Keys box container widget. |
94+
| `.keys .key` | Individual key indicator container widget. |
95+
| `.keys .key.enabled` | Key indicator where key is toggled on. |
96+
| `.keys .key.caps` | Capslock key indicator. |
97+
| `.keys .key.num` | Num lock key indicator. |
98+
| `.keys .key.scroll` | Scroll lock key indicator. |
99+
| `.keys .key.image` | Key indicator image icon. |
100+
| `.keys .key.text-icon` | Key indicator textual icon. |
101+
102+
For more information on styling, please see the [styling guide](styling-guide).

Diff for: docs/modules/Music.md

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ in MPRIS mode, the widget will listen to all players and automatically detect/di
3333
| `host` | `string` | `localhost:6600` | [MPD Only] TCP or Unix socket for the MPD server. |
3434
| `music_dir` | `string` | `$HOME/Music` | [MPD Only] Path to MPD server's music directory on disc. Required for album art. |
3535

36-
See [here](images) for information on images.
37-
3836
<details>
3937
<summary>JSON</summary>
4038

Diff for: examples/test.corn

-60
This file was deleted.

0 commit comments

Comments
 (0)