-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add a config to enable the NumLock key on login #291
Comments
TL;DR: I think Smithay needs to grow support for this for us to take advantage of. Last weekend, I poked around at this (with my lacking knowledge of Wayland itself) and only got far enough to realize this likely needs some additional support in Smithay. Specifically, I couldn't find a way to set the locked modifiers (so as to enable numlock). Here's the very, very barebones and not working diff I was using to play around (I also patched Smithay to make the state fields public so I could actually print them, but otherwise this is as far as I got): diff --git a/Cargo.lock b/Cargo.lock
index eed1cf8..f3579bf 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3116,7 +3116,6 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
[[package]]
name = "smithay"
version = "0.3.0"
-source = "git+https://github.com/Smithay/smithay.git#c5e9a697e41f50dc56b918d9ef1e3d2e52c84ac0"
dependencies = [
"appendlist",
"bitflags 2.5.0",
diff --git a/Cargo.toml b/Cargo.toml
index 51c2ae0..a3d0d44 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,8 +20,8 @@ tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracy-client = { version = "0.17.0", default-features = false }
[workspace.dependencies.smithay]
-git = "https://github.com/Smithay/smithay.git"
-# path = "../smithay"
+# git = "https://github.com/Smithay/smithay.git"
+path = "../smithay"
default-features = false
[workspace.dependencies.smithay-drm-extras]
diff --git a/niri-config/src/lib.rs b/niri-config/src/lib.rs
index d88ee13..c22ac05 100644
--- a/niri-config/src/lib.rs
+++ b/niri-config/src/lib.rs
@@ -104,6 +104,8 @@ pub struct Xkb {
pub variant: String,
#[knuffel(child, unwrap(argument))]
pub options: Option<String>,
+ #[knuffel(child)]
+ pub numlock_enabled: bool,
}
impl Xkb {
diff --git a/src/input.rs b/src/input.rs
index 49546fa..97d7785 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -150,13 +150,24 @@ impl State {
}
if device.has_capability(input::DeviceCapability::Keyboard) {
- if let Some(led_state) = self
- .niri
- .seat
- .get_keyboard()
- .map(|keyboard| keyboard.led_state())
- {
- device.led_update(led_state.into());
+ if let Some(keyboard) = self.niri.seat.get_keyboard() {
+ let a = self.niri.config.borrow().input.keyboard.xkb.numlock_enabled;
+ error!("{:?}", &a);
+
+ keyboard.with_xkb_state(self, |mut state| {
+ error!("{:?}", &state.mods_state);
+ error!("{:?}", &state.leds_state);
+ state.mods_state.num_lock = a;
+ *state.mods_changed = true;
+ state.leds_state.num = Some(a);
+ *state.leds_changed = true;
+ error!("{:?}", &state.mods_state);
+ error!("{:?}", &state.leds_state);
+ error!("{:?}", &state.leds_changed);
+ error!("{:?}", &state.mods_changed);
+ });
+
+ device.led_update(keyboard.led_state().into());
}
} |
For reference, this is where NumLock LED tracking was added (and see linked Smithay PR): #127 |
Discussed in #290
Originally posted by stepanzak April 14, 2024
Hi, I wasn't able to find a simple way to enable the NumLock key on login to Niri session, so I don't have to press NumLock to be able to type on numerical keyboard. In fact, I wasn't able to find any way to do that. Running the
numlockl on
command using Numlockl turns the NumLock on, but running it with spawn-at-startup or as a user systemd service doesn't. Both Hyprland and Sway have a config to enable it, so I think it would be awesome if Niri had it too.The text was updated successfully, but these errors were encountered: