forge
Explore
Log in

Don't you dare go Hollow

Add a few mouse libinput settings

Browse files at this commit

71fef2ad2e873c45279cdd6e629218fb5dea1115Ivan MolodetskikhParent: c6841f1
niri-config/src/lib.rsmodified+23 -0
@@ -48,6 +48,8 @@ pub struct Input {
48 #[knuffel(child, default)]48 #[knuffel(child, default)]
49 pub touchpad: Touchpad,49 pub touchpad: Touchpad,
50 #[knuffel(child, default)]50 #[knuffel(child, default)]
51+ pub mouse: Mouse,
52+ #[knuffel(child, default)]
51 pub tablet: Tablet,53 pub tablet: Tablet,
52 #[knuffel(child)]54 #[knuffel(child)]
53 pub disable_power_key_handling: bool,55 pub disable_power_key_handling: bool,
@@ -118,6 +120,16 @@ pub struct Touchpad {
118 pub tap_button_map: Option<TapButtonMap>,120 pub tap_button_map: Option<TapButtonMap>,
119 }121 }
120 122
123+#[derive(knuffel::Decode, Debug, Default, PartialEq)]
124+pub struct Mouse {
125+ #[knuffel(child)]
126+ pub natural_scroll: bool,
127+ #[knuffel(child, unwrap(argument), default)]
128+ pub accel_speed: f64,
129+ #[knuffel(child, unwrap(argument, str))]
130+ pub accel_profile: Option<AccelProfile>,
131+}
132+
121 #[derive(Debug, Clone, Copy, PartialEq, Eq)]133 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
122 pub enum AccelProfile {134 pub enum AccelProfile {
123 Adaptive,135 Adaptive,
@@ -679,6 +691,12 @@ mod tests {
679 tap-button-map "left-middle-right"691 tap-button-map "left-middle-right"
680 }692 }
681 693
694+ mouse {
695+ natural-scroll
696+ accel-speed 0.4
697+ accel-profile "flat"
698+ }
699+
682 tablet {700 tablet {
683 map-to-output "eDP-1"701 map-to-output "eDP-1"
684 }702 }
@@ -768,6 +786,11 @@ mod tests {
768 accel_profile: Some(AccelProfile::Flat),786 accel_profile: Some(AccelProfile::Flat),
769 tap_button_map: Some(TapButtonMap::LeftMiddleRight),787 tap_button_map: Some(TapButtonMap::LeftMiddleRight),
770 },788 },
789+ mouse: Mouse {
790+ natural_scroll: true,
791+ accel_speed: 0.4,
792+ accel_profile: Some(AccelProfile::Flat),
793+ },
771 tablet: Tablet {794 tablet: Tablet {
772 map_to_output: Some("eDP-1".to_owned()),795 map_to_output: Some("eDP-1".to_owned()),
773 },796 },
resources/default-config.kdlmodified+6 -0
@@ -34,6 +34,12 @@ input {
34 // tap-button-map "left-middle-right"34 // tap-button-map "left-middle-right"
35 }35 }
36 36
37+ mouse {
38+ // natural-scroll
39+ // accel-speed 0.2
40+ // accel-profile "flat"
41+ }
42+
37 tablet {43 tablet {
38 // Set the name of the output (see below) which the tablet will map to.44 // Set the name of the output (see below) which the tablet will map to.
39 // If this is unset or the output doesn't exist, the tablet maps to one of the45 // If this is unset or the output doesn't exist, the tablet maps to one of the
src/input.rsmodified+29 -0
@@ -119,6 +119,35 @@ impl State {
119 }119 }
120 }120 }
121 }121 }
122+
123+ // This is how Mutter tells apart mice.
124+ let mut is_trackball = false;
125+ let mut is_trackpoint = false;
126+ if let Some(udev_device) = unsafe { device.udev_device() } {
127+ if udev_device.property_value("ID_INPUT_TRACKBALL").is_some() {
128+ is_trackball = true;
129+ }
130+ if udev_device
131+ .property_value("ID_INPUT_POINTINGSTICK")
132+ .is_some()
133+ {
134+ is_trackpoint = true;
135+ }
136+ }
137+
138+ let is_mouse = device.has_capability(input::DeviceCapability::Pointer)
139+ && !is_touchpad
140+ && !is_trackball
141+ && !is_trackpoint;
142+ if is_mouse {
143+ let c = &self.niri.config.borrow().input.mouse;
144+ let _ = device.config_scroll_set_natural_scroll_enabled(c.natural_scroll);
145+ let _ = device.config_accel_set_speed(c.accel_speed);
146+
147+ if let Some(accel_profile) = c.accel_profile {
148+ let _ = device.config_accel_set_profile(accel_profile.into());
149+ }
150+ }
122 }151 }
123 InputEvent::DeviceRemoved { device } => {152 InputEvent::DeviceRemoved { device } => {
124 self.niri.tablets.remove(device);153 self.niri.tablets.remove(device);