mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
feat: implement support to enable numlock at startup
Signed-off-by: erdii <me@erdii.engineering>
This commit is contained in:
@@ -120,6 +120,8 @@ pub struct Keyboard {
|
||||
pub repeat_rate: u8,
|
||||
#[knuffel(child, unwrap(argument), default)]
|
||||
pub track_layout: TrackLayout,
|
||||
#[knuffel(child)]
|
||||
pub numlock: bool,
|
||||
}
|
||||
|
||||
impl Default for Keyboard {
|
||||
@@ -129,6 +131,7 @@ impl Default for Keyboard {
|
||||
repeat_delay: 600,
|
||||
repeat_rate: 25,
|
||||
track_layout: Default::default(),
|
||||
numlock: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4059,6 +4062,7 @@ mod tests {
|
||||
repeat_delay: 600,
|
||||
repeat_rate: 25,
|
||||
track_layout: Window,
|
||||
numlock: false,
|
||||
},
|
||||
touchpad: Touchpad {
|
||||
off: false,
|
||||
|
||||
@@ -16,6 +16,9 @@ input {
|
||||
// layout "us,ru"
|
||||
// options "grp:win_space_toggle,compose:ralt,ctrl:nocaps"
|
||||
}
|
||||
|
||||
// Enable numlock on startup, omitting this setting disables it.
|
||||
numlock
|
||||
}
|
||||
|
||||
// Next sections include libinput settings.
|
||||
|
||||
+19
-11
@@ -2248,22 +2248,30 @@ impl Niri {
|
||||
let single_pixel_buffer_state = SinglePixelBufferState::new::<State>(&display_handle);
|
||||
|
||||
let mut seat: Seat<State> = seat_state.new_wl_seat(&display_handle, backend.seat_name());
|
||||
if let Err(err) = seat.add_keyboard(
|
||||
let keyboard = match seat.add_keyboard(
|
||||
config_.input.keyboard.xkb.to_xkb_config(),
|
||||
config_.input.keyboard.repeat_delay.into(),
|
||||
config_.input.keyboard.repeat_rate.into(),
|
||||
) {
|
||||
if let smithay::input::keyboard::Error::BadKeymap = err {
|
||||
warn!("error loading the configured xkb keymap, trying default");
|
||||
} else {
|
||||
warn!("error adding keyboard: {err:?}");
|
||||
Err(err) => {
|
||||
if let smithay::input::keyboard::Error::BadKeymap = err {
|
||||
warn!("error loading the configured xkb keymap, trying default");
|
||||
} else {
|
||||
warn!("error adding keyboard: {err:?}");
|
||||
}
|
||||
seat.add_keyboard(
|
||||
Default::default(),
|
||||
config_.input.keyboard.repeat_delay.into(),
|
||||
config_.input.keyboard.repeat_rate.into(),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
seat.add_keyboard(
|
||||
Default::default(),
|
||||
config_.input.keyboard.repeat_delay.into(),
|
||||
config_.input.keyboard.repeat_rate.into(),
|
||||
)
|
||||
.unwrap();
|
||||
Ok(keyboard) => keyboard,
|
||||
};
|
||||
if config_.input.keyboard.numlock {
|
||||
let mut modifier_state = keyboard.modifier_state();
|
||||
modifier_state.num_lock = true;
|
||||
keyboard.set_modifier_state(modifier_state);
|
||||
}
|
||||
seat.add_pointer();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user