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

Add keyboard.repeat-rate and keyboard.repeat-delay #8

Merged
merged 1 commit into from
Sep 16, 2023
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
8 changes: 8 additions & 0 deletions resources/default-config.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

input {
keyboard {
// Control the repeat rate of the keyboard.

// Repeat delay in milliseconds.
repeat-delay 660

// Repeat rate in characters per second.
repeat-rate 25

xkb {
// You can set rules, model, layout, variant and options.
// For more information, see xkeyboard-config(7).
Expand Down
10 changes: 10 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ pub struct Input {
pub struct Keyboard {
#[knuffel(child, default)]
pub xkb: Xkb,
// The default value represents the one used by Xorg.
#[knuffel(child, unwrap(argument), default = 660)]
pub repeat_delay: u16,
// The default value represents the one used by Xorg.
#[knuffel(child, unwrap(argument), default = 25)]
pub repeat_rate: u8,
}

#[derive(knuffel::Decode, Debug, Default, PartialEq, Eq)]
Expand Down Expand Up @@ -244,6 +250,8 @@ mod tests {
r#"
input {
keyboard {
repeat-delay 660
repeat-rate 25
xkb {
layout "us,ru"
options "grp:win_space_toggle"
Expand Down Expand Up @@ -277,6 +285,8 @@ mod tests {
options: Some("grp:win_space_toggle".to_owned()),
..Default::default()
},
repeat_delay: 660,
repeat_rate: 25,
},
touchpad: Touchpad {
tap: true,
Expand Down
7 changes: 6 additions & 1 deletion src/niri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,12 @@ impl Niri {
variant: &config_.input.keyboard.xkb.variant,
options: config_.input.keyboard.xkb.options.clone(),
};
seat.add_keyboard(xkb, 400, 30).unwrap();
seat.add_keyboard(
xkb,
config_.input.keyboard.repeat_delay as i32,
config_.input.keyboard.repeat_rate as i32,
)
.unwrap();
seat.add_pointer();

let socket_source = ListeningSocketSource::new_auto().unwrap();
Expand Down