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

nixos/libinput: change mouse device defaults #110350

Closed
wants to merge 5 commits into from
Closed

nixos/libinput: change mouse device defaults #110350

wants to merge 5 commits into from

Conversation

thiagokokada
Copy link
Contributor

@thiagokokada thiagokokada commented Jan 21, 2021

Motivation for this change

This commit changes some mouse device defaults that doesn't make sense (generally) for a mouse, like tapping/tappingDragLock or middleEmulation (it works in mouses, but unless you have a mouse with
only 3 buttons it doesn't make much sense to have it enabled). They're now set to false or null depending of the case.

Since those options can still be useful in some exotic cases, instead of disabling those options in mouse, I set them with visible = false;. This way, they don't show in manual, but in the case the user needs it can still be set.

Also, I moved services.xserver.synaptics config from services.xserver.config to services.xserver.inputClassSections. The reason is the same as stated here: https://github.com/NixOS/nixpkgs/pull/108909/files#r555458053.

Added some tests for services.xserver.libinput module to make sure it will keep working as it should.

Continuation of PR #108909.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@thiagokokada
Copy link
Contributor Author

CC @lheckemann @worldofpeace (if you're feeling better).

@thiagokokada
Copy link
Contributor Author

Tested in my notebook:

  • services.xserver.libinput module continue working as it should (mouse ok, touchpad ok)
  • Quick test in services.xserver.synpatics module (mouse ok, touchpad ok)

@thiagokokada
Copy link
Contributor Author

Since I learned a lot while looking for the issues in this module, I added myself as maintainer.

But since those more core modules doesn't seem to have maintainers, if someone is against it I can remove.

@@ -85,7 +91,7 @@ let cfg = config.services.xserver.libinput;

middleEmulation = mkOption {
type = types.bool;
default = true;
default = mkDefaultForDevice deviceType { };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option makes sense if your mouse have only two buttons (I think this is the case even for some recent mouses, like Logitech MX Master series, where the scroll doesn't click). But setting the default to false since most mouses have three buttons (generally the scroll is the middle button).

default = "twofinger";
type = types.nullOr (types.enum [ "twofinger" "edge" "button" "none" ]);
default = mkDefaultForDevice deviceType { mouse = null; touchpad = "twofinger"; };
visible = mkDefaultForDevice deviceType { };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hiding this since this settings seems only to make sense for touchpads. Allowing null values so it doesn't show in mouse configuration.

default = true;
type = types.nullOr types.bool;
default = mkDefaultForDevice deviceType { mouse = null; touchpad = true; };
visible = mkDefaultForDevice deviceType { };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hiding this since this settings seems only to make sense for touchpads. Allowing null values so it doesn't show in mouse configuration.

default = true;
type = types.nullOr types.bool;
default = mkDefaultForDevice deviceType { mouse = null; touchpad = true; };
visible = mkDefaultForDevice deviceType { };
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hiding this since this settings seems only to make sense for touchpads. Allowing null values so it doesn't show in mouse configuration.

@thiagokokada
Copy link
Contributor Author

@GrahamcOfBorg test libinput

@thiagokokada
Copy link
Contributor Author

/marvin opt-in
/status needs_reviewer

@marvin-mk2 marvin-mk2 bot added the marvin label Jan 24, 2021
@marvin-mk2
Copy link

marvin-mk2 bot commented Jan 24, 2021

Hi! I'm an experimental bot. My goal is to guide this PR through its stages, hopefully ending with a merge. You can read up on the usage here.

@marvin-mk2
Copy link

marvin-mk2 bot commented Jan 30, 2021

Reminder: Please review!

This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR will be should be put back in the needs_reviewer queue in one day.


Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually.

1 similar comment
@marvin-mk2
Copy link

marvin-mk2 bot commented Feb 2, 2021

Reminder: Please review!

This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR will be should be put back in the needs_reviewer queue in one day.


Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually.

@thiagokokada
Copy link
Contributor Author

Would splitting this PR in smaller parts make it easier to review? The most important part (the changes to libinput module) can be only one separate PR for example, while the other changes (the refactoring in synaptics, tests) can be another PRs.

WDYT @lheckemann ?

@jdnixx
Copy link

jdnixx commented Feb 7, 2021

Hey, I'm not sure if this could be the source of the problem or not but I've been having issues with my Logitech G602 for the past few weeks on unstable. I just remembered I saw the red text telling me services.xserver.libinput.* (everything except enable) was deprecated, so I was like, ok cool I'll just move all my configuration.nix options under that, to be under libinput.touchpad.

Now, the touchpad is still fine but the mouse does this weird thing where after a few seconds of inactivity, upon moving it it seems to be totally disabled for ~2s before finally waking up and functioning again. I also reinstalled nixos from scratch about a week ago, and since then for some reason, now it does that AND the extra side buttons (everything besides left/right/middle,scroll/back/forward) doesn't work. xev reports nothing from those buttons and also nothing during that 2s disabled period prior to waking up.

Output of my nixos-option services.xserver.libinput -r:

trace: Obsolete option `services.xserver.libinput.accelProfile' is used. It was renamed to `services.xserver.libinput.touchpad.accelProfile'.
services.xserver.libinput.accelProfile = "adaptive";
trace: Obsolete option `services.xserver.libinput.accelSpeed' is used. It was renamed to `services.xserver.libinput.touchpad.accelSpeed'.
services.xserver.libinput.accelSpeed = null;
trace: Obsolete option `services.xserver.libinput.additionalOptions' is used. It was renamed to `services.xserver.libinput.touchpad.additionalOptions'.
services.xserver.libinput.additionalOptions = "";
trace: Obsolete option `services.xserver.libinput.buttonMapping' is used. It was renamed to `services.xserver.libinput.touchpad.buttonMapping'.
services.xserver.libinput.buttonMapping = null;
trace: Obsolete option `services.xserver.libinput.calibrationMatrix' is used. It was renamed to `services.xserver.libinput.touchpad.calibrationMatrix'.
services.xserver.libinput.calibrationMatrix = null;
trace: Obsolete option `services.xserver.libinput.clickMethod' is used. It was renamed to `services.xserver.libinput.touchpad.clickMethod'.
services.xserver.libinput.clickMethod = "clickfinger";
trace: Obsolete option `services.xserver.libinput.disableWhileTyping' is used. It was renamed to `services.xserver.libinput.touchpad.disableWhileTyping'.
services.xserver.libinput.disableWhileTyping = true;
services.xserver.libinput.enable = true;
trace: Obsolete option `services.xserver.libinput.horizontalScrolling' is used. It was renamed to `services.xserver.libinput.touchpad.horizontalScrolling'.
services.xserver.libinput.horizontalScrolling = true;
trace: Obsolete option `services.xserver.libinput.leftHanded' is used. It was renamed to `services.xserver.libinput.touchpad.leftHanded'.
services.xserver.libinput.leftHanded = false;
trace: Obsolete option `services.xserver.libinput.middleEmulation' is used. It was renamed to `services.xserver.libinput.touchpad.middleEmulation'.
services.xserver.libinput.middleEmulation = false;
services.xserver.libinput.mouse.accelProfile = "adaptive";
services.xserver.libinput.mouse.accelSpeed = null;
services.xserver.libinput.mouse.additionalOptions = "";
services.xserver.libinput.mouse.buttonMapping = null;
services.xserver.libinput.mouse.calibrationMatrix = null;
services.xserver.libinput.mouse.clickMethod = null;
services.xserver.libinput.mouse.dev = null;
services.xserver.libinput.mouse.disableWhileTyping = false;
services.xserver.libinput.mouse.horizontalScrolling = true;
services.xserver.libinput.mouse.leftHanded = false;
services.xserver.libinput.mouse.middleEmulation = true;
services.xserver.libinput.mouse.naturalScrolling = false;
services.xserver.libinput.mouse.scrollButton = null;
services.xserver.libinput.mouse.scrollMethod = "twofinger";
services.xserver.libinput.mouse.sendEventsMode = "enabled";
services.xserver.libinput.mouse.tapping = true;
services.xserver.libinput.mouse.tappingDragLock = true;
trace: Obsolete option `services.xserver.libinput.naturalScrolling' is used. It was renamed to `services.xserver.libinput.touchpad.naturalScrolling'.
services.xserver.libinput.naturalScrolling = true;
trace: Obsolete option `services.xserver.libinput.scrollButton' is used. It was renamed to `services.xserver.libinput.touchpad.scrollButton'.
services.xserver.libinput.scrollButton = 3;
trace: Obsolete option `services.xserver.libinput.scrollMethod' is used. It was renamed to `services.xserver.libinput.touchpad.scrollMethod'.
services.xserver.libinput.scrollMethod = "twofinger";
trace: Obsolete option `services.xserver.libinput.sendEventsMode' is used. It was renamed to `services.xserver.libinput.touchpad.sendEventsMode'.
services.xserver.libinput.sendEventsMode = "enabled";
trace: Obsolete option `services.xserver.libinput.tapping' is used. It was renamed to `services.xserver.libinput.touchpad.tapping'.
services.xserver.libinput.tapping = true;
trace: Obsolete option `services.xserver.libinput.tappingDragLock' is used. It was renamed to `services.xserver.libinput.touchpad.tappingDragLock'.
services.xserver.libinput.tappingDragLock = false;
services.xserver.libinput.touchpad.accelProfile = "adaptive";
services.xserver.libinput.touchpad.accelSpeed = null;
services.xserver.libinput.touchpad.additionalOptions = "";
services.xserver.libinput.touchpad.buttonMapping = null;
services.xserver.libinput.touchpad.calibrationMatrix = null;
services.xserver.libinput.touchpad.clickMethod = "clickfinger";
services.xserver.libinput.touchpad.dev = null;
services.xserver.libinput.touchpad.disableWhileTyping = true;
services.xserver.libinput.touchpad.horizontalScrolling = true;
services.xserver.libinput.touchpad.leftHanded = false;
services.xserver.libinput.touchpad.middleEmulation = false;
services.xserver.libinput.touchpad.naturalScrolling = true;
services.xserver.libinput.touchpad.scrollButton = 3;
services.xserver.libinput.touchpad.scrollMethod = "twofinger";
services.xserver.libinput.touchpad.sendEventsMode = "enabled";
services.xserver.libinput.touchpad.tapping = true;
services.xserver.libinput.touchpad.tappingDragLock = false;

@thiagokokada
Copy link
Contributor Author

thiagokokada commented Feb 7, 2021

Now, the touchpad is still fine but the mouse does this weird thing where after a few seconds of inactivity, upon moving it it seems to be totally disabled for ~2s before finally waking up and functioning again.

Looks like USB power saving. Do you use powertop, TLP or something like this? They have USB power savings enabled at a pretty aggressive mode.

the extra side buttons (everything besides left/right/middle,scroll/back/forward) doesn't work.

This may be related to PR #108909. But like the PR said, you need to configure your mouse separately. If you want exactly same behavior between mouse and touchpad, you can have something like this in your config:

let
  libinputConfig = {
    naturalScrolling = true;
    ...
  };
in {
  xserver.libinput.touchpad = libinputConfig // { accelProfile = "adaptative"; };
  xserver.libinput.mouse = libinputConfig // { accelProfile = "flat"; };
}

If this doesn't work them it is probably not #108909, maybe some other PR for libinput or something else.

P.S.: this PR can't be at fault since it is not merged.

@lheckemann
Copy link
Member

I find the mkDefaultForDevice approach a little awkward. Maybe prefer only defining the relevant options for the given type, i.e. remove scrollMethod, tapping, and tappingDragLock from mkConfigForDevice and add them only to the touchpad further down:

mouse = mkConfigForDevice "mouse";
touchpad = (mkConfigForDevice "touchpad") // {
  scrollMethod = mkOption {…};
  tapping = mkOption {…};
  tappingDragLock = mkOption {…};
};

@thiagokokada
Copy link
Contributor Author

I find the mkDefaultForDevice approach a little awkward. Maybe prefer only defining the relevant options for the given type, i.e. remove scrollMethod, tapping, and tappingDragLock from mkConfigForDevice and add them only to the touchpad further down:

mouse = mkConfigForDevice "mouse";
touchpad = (mkConfigForDevice "touchpad") // {
  scrollMethod = mkOption {…};
  tapping = mkOption {…};
  tappingDragLock = mkOption {…};
};

I did it like this because accordingly to libinput documentation it hint that those options can also make sense in some exotic peripherals (maybe a mouse with a touch surface like a Apple Magic Mouse, for example). So I decided to hide them instead of removing them, so if the user has some of those exotic devices they can still use those options if needed.

I can remove the mkDefaultForDevice though and simply put the code directly in the options since even I thought that the code seems convoluted right now.

@thiagokokada
Copy link
Contributor Author

thiagokokada commented Feb 9, 2021

Did the change and rebased. WDYT @lheckemann?

@jdnixx
Copy link

jdnixx commented Feb 9, 2021

Now, the touchpad is still fine but the mouse does this weird thing where after a few seconds of inactivity, upon moving it it seems to be totally disabled for ~2s before finally waking up and functioning again.

Looks like USB power saving. Do you use powertop, TLP or something like this? They have USB power savings enabled at a pretty aggressive mode.

the extra side buttons (everything besides left/right/middle,scroll/back/forward) doesn't work.

This may be related to PR #108909. But like the PR said, you need to configure your mouse separately. If you want exactly same behavior between mouse and touchpad, you can have something like this in your config:

let
  libinputConfig = {
    naturalScrolling = true;
    ...
  };
in {
  xserver.libinput.touchpad = libinputConfig // { accelProfile = "adaptative"; };
  xserver.libinput.mouse = libinputConfig // { accelProfile = "flat"; };
}

If this doesn't work them it is probably not #108909, maybe some other PR for libinput or something else.

P.S.: this PR can't be at fault since it is not merged.

Lol my bad, you're absolutely right I didn't even notice. Think I just searched the issues and clicked the first thing with libinput in the title, "that has to be it"... haha thank you anyway. That was helpful, powertop was indeed the culprit with the sleeping thing; still investigating the buttons but I'm still a newb to nix the language and coincidentally always wondered how to merge options like that.

@marvin-mk2
Copy link

marvin-mk2 bot commented Feb 16, 2021

Reminder: Please review!

This Pull Request is awaiting review. If you are the assigned reviewer, please have a look. Try to find another reviewer if necessary. If you can't, please say so. If the status is not accurate, please change it. If nothing happens, this PR will be should be put back in the needs_reviewer queue in one day.


Note: This feature is currently broken. The bot will not actually change the status. If you see this message multiple times, please request a status change manually.

@NixOS NixOS deleted a comment from marvin-mk2 bot Feb 16, 2021
@lheckemann
Copy link
Member

lheckemann commented Feb 18, 2021

Sorry for taking so long.

An unrelated change seems to have sneaked in to d726fc9717e406fdd361aeda25972265631cfc91.

I don't have the energy to review the main content currently, sorry.

This commit changes some mouse device defaults that doesn't make sense
(generally) for a mouse, like tapping/tappingDragLock or
middleEmulation (it works in mouses, but unless you have a mouse with
only 3 buttons it doesn't make much sense to have it enabled). They're
now set to false or null depending of the case.

Since those options can still be useful in some exotic cases, instead of
disabling those options in mouse, I set them with `visible = false;`.
This way, they don't show in manual, but in the case the user needs it
can still be set.
@thiagokokada
Copy link
Contributor Author

thiagokokada commented Feb 18, 2021

@lheckemann Removed, thanks.

I don't have the energy to review the main content currently, sorry.

Ok, no problem.

@thiagokokada
Copy link
Contributor Author

@worldofpeace If you're feeling better can you review this PR?

@worldofpeace
Copy link
Contributor

@worldofpeace If you're feeling better can you review this PR?

You're in luck, I'm active again (supposedly)

@stale
Copy link

stale bot commented Aug 22, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 22, 2021
@stale stale bot removed 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md labels Aug 22, 2021
@thiagokokada
Copy link
Contributor Author

Closing some old PRs of mine.

@thiagokokada thiagokokada deleted the refactor-libinput-pt2 branch January 11, 2022 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants