Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: libinput keys module #783

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/scripts/ubuntu_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $SUDO apt-get update && $SUDO apt-get install --assume-yes \
libssl-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
libgtk-3-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
libgtk-layer-shell-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
libinput-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
libdbusmenu-gtk3-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
libpulse-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH} \
libluajit-5.1-dev${CROSS_DEB_ARCH:+:$CROSS_DEB_ARCH}
78 changes: 71 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ default = [
"focused",
"http",
"ipc",
"keys",
"launcher",
"music+all",
"network_manager",
Expand Down Expand Up @@ -49,12 +50,14 @@ http = ["dep:reqwest"]

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

clipboard = ["nix"]
clipboard = ["dep:nix"]

clock = ["chrono"]

focused = []

keys = ["dep:input", "dep:evdev-rs", "dep:libc", "dep:nix"]

launcher = []

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

# clipboard
nix = { version = "0.29.0", optional = true, features = ["event", "fs"] }

# clock
chrono = { version = "0.4.39", optional = true, default-features = false, features = ["clock", "unstable-locales"] }

# keys
input = { version = "0.9.1", optional = true }
evdev-rs = { version = "0.6.1", optional = true }
libc = { version = "0.2.164", optional = true }

# music
mpd-utils = { version = "0.2.1", optional = true }
mpris = { version = "2.0.1", optional = true }
Expand All @@ -163,6 +168,7 @@ futures-util = { version = "0.3.31", optional = true }

# shared
futures-lite = { version = "2.5.0", optional = true } # network_manager, upower, workspaces
nix = { version = "0.29.0", optional = true, features = ["event", "fs", "poll"] } # clipboard, input
regex = { version = "1.11.1", default-features = false, features = [
"std",
], optional = true } # music, sys_info
Expand Down
6 changes: 6 additions & 0 deletions docs/Compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pacman -S openssl
pacman -S libdbusmenu-gtk3
# for volume support
pacman -S libpulse
# for keys support
pacman -S libinput
# for lua/cairo support
pacman -S luajit lua51-lgi
```
Expand All @@ -40,6 +42,8 @@ apt install libssl-dev
apt install libdbusmenu-gtk3-dev
# for volume support
apt install libpulse-dev
# for keys support
apt install libinput-dev
# for lua/cairo support
apt install luajit-dev lua-lgi
```
Expand All @@ -54,6 +58,8 @@ dnf install openssl-devel
dnf install libdbusmenu-gtk3-devel
# for volume support
dnf install pulseaudio-libs-devel
# for keys support
dnf install libinput-devel
# for lua/cairo support
dnf install luajit-devel lua-lgi
```
Expand Down
102 changes: 102 additions & 0 deletions docs/modules/Keys.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
> [!NOTE]
> This module requires your user is in the `input` group.

Displays the toggle state of the capslock, num lock and scroll lock keys.

![Screenshot of clock widget with popup open](https://f.jstanger.dev/github/ironbar/keys.png)

## 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).
2 changes: 0 additions & 2 deletions docs/modules/Music.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ in MPRIS mode, the widget will listen to all players and automatically detect/di
| `host` | `string` | `localhost:6600` | [MPD Only] TCP or Unix socket for the MPD server. |
| `music_dir` | `string` | `$HOME/Music` | [MPD Only] Path to MPD server's music directory on disc. Required for album art. |

See [here](images) for information on images.

<details>
<summary>JSON</summary>

Expand Down
60 changes: 0 additions & 60 deletions examples/test.corn

This file was deleted.

Loading
Loading