forge
Explore
Log in

Don't you dare go Hollow

input: enable configuring of trackpoint devices

Browse files at this commit

363e1d876492a26a1b7d5261ac28aba94f323d08Viktor PocedulicParent: 8e1d4de
niri-config/src/lib.rsmodified+23 -0
@@ -57,6 +57,8 @@ pub struct Input {
5757 #[knuffel(child, default)]
5858 pub mouse: Mouse,
5959 #[knuffel(child, default)]
60+ pub trackpoint: Trackpoint,
61+ #[knuffel(child, default)]
6062 pub tablet: Tablet,
6163 #[knuffel(child)]
6264 pub disable_power_key_handling: bool,
@@ -151,6 +153,16 @@ pub struct Mouse {
151153 pub accel_profile: Option<AccelProfile>,
152154 }
153155
156+#[derive(knuffel::Decode, Debug, Default, PartialEq)]
157+pub struct Trackpoint {
158+ #[knuffel(child)]
159+ pub natural_scroll: bool,
160+ #[knuffel(child, unwrap(argument), default)]
161+ pub accel_speed: f64,
162+ #[knuffel(child, unwrap(argument, str))]
163+ pub accel_profile: Option<AccelProfile>,
164+}
165+
154166 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
155167 pub enum AccelProfile {
156168 Adaptive,
@@ -924,6 +936,12 @@ mod tests {
924936 accel-profile "flat"
925937 }
926938
939+ trackpoint {
940+ natural-scroll
941+ accel-speed 0.0
942+ accel-profile "flat"
943+ }
944+
927945 tablet {
928946 map-to-output "eDP-1"
929947 }
@@ -1043,6 +1061,11 @@ mod tests {
10431061 accel_speed: 0.4,
10441062 accel_profile: Some(AccelProfile::Flat),
10451063 },
1064+ trackpoint: Trackpoint {
1065+ natural_scroll: true,
1066+ accel_speed: 0.0,
1067+ accel_profile: Some(AccelProfile::Flat),
1068+ },
10461069 tablet: Tablet {
10471070 map_to_output: Some("eDP-1".to_owned()),
10481071 },
resources/default-config.kdlmodified+6 -0
@@ -41,6 +41,12 @@ input {
4141 // accel-profile "flat"
4242 }
4343
44+ trackpoint {
45+ // natural-scroll
46+ // accel-speed 0.2
47+ // accel-profile "flat"
48+ }
49+
4450 tablet {
4551 // Set the name of the output (see below) which the tablet will map to.
4652 // If this is unset or the output doesn't exist, the tablet maps to one of the
src/input.rsmodified+12 -0
@@ -1622,6 +1622,18 @@ pub fn apply_libinput_settings(config: &niri_config::Input, device: &mut input::
16221622 let _ = device.config_accel_set_profile(default);
16231623 }
16241624 }
1625+
1626+ if is_trackpoint {
1627+ let c = &config.trackpoint;
1628+ let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll);
1629+ let _ = device.config_accel_set_speed(c.accel_speed);
1630+
1631+ if let Some(accel_profile) = c.accel_profile {
1632+ let _ = device.config_accel_set_profile(accel_profile.into());
1633+ } else if let Some(default) = device.config_accel_default_profile() {
1634+ let _ = device.config_accel_set_profile(default);
1635+ }
1636+ }
16251637 }
16261638
16271639 #[cfg(test)]
src/niri.rsmodified+1 -0
@@ -628,6 +628,7 @@ impl State {
628628
629629 if config.input.touchpad != old_config.input.touchpad
630630 || config.input.mouse != old_config.input.mouse
631+ || config.input.trackpoint != old_config.input.trackpoint
631632 {
632633 libinput_config_changed = true;
633634 }