Skip to content

fix: prevent powertop autosuspend on touchpad for idle detection - #1333

Merged
shunkakinoki merged 2 commits into
mainfrom
fix/touchpad-idle-detection
Apr 3, 2026
Merged

fix: prevent powertop autosuspend on touchpad for idle detection#1333
shunkakinoki merged 2 commits into
mainfrom
fix/touchpad-idle-detection

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Apr 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds udev rule to keep touchpad power control as on, preventing powertop --auto-tune from enabling autosuspend on the PIXA3854 touchpad
  • Fixes hypridle not detecting mouse/touchpad input on battery, causing false idle triggers (screen dim, lock, suspend) even during active use

Root cause

powertop --auto-tune sets touchpad power/control to auto, which allows the kernel to suspend the touchpad after brief inactivity on battery. When suspended, touchpad events don't reach Hyprland, so hypridle thinks the system is idle.

Test plan

  • Rebuild and switch on matic
  • Verify cat /sys/bus/i2c/devices/i2c-PIXA3854:00/power/control shows on after reboot
  • Confirm screen doesn't dim/lock while actively using touchpad on battery

Summary by cubic

Prevents touchpad autosuspend so idle detection works on battery and stops false screen dim/lock. Also ignores lid-close events so hypridle manages suspend consistently.

  • Bug Fixes
    • Add udev rule to keep PIXA3854 touchpad power/control set to on, overriding powertop --auto-tune and restoring input events to hypridle.
    • Set logind HandleLidSwitch to ignore on battery and AC, relying on hypridle timers for suspend.

Written for commit ba5c582. Summary will update on new commits.

Copilot AI review requested due to automatic review settings April 2, 2026 16:42
@mesa-dot-dev

mesa-dot-dev Bot commented Apr 2, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented Apr 2, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5dfdd042-7d49-4aa9-b62c-6ceacceb321d

📥 Commits

Reviewing files that changed from the base of the PR and between 099513a and 2b5ebaf.

📒 Files selected for processing (1)
  • named-hosts/matic/default.nix

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed touchpad auto-suspend behavior that was affecting battery idle detection
    • Updated lid-close handling to ignore lid close events on both battery and AC power instead of suspending the system

Walkthrough

This PR modifies system power management configuration for a NixOS host. It adds a udev rule to prevent autosuspend of the touchpad's I2C HID device and changes logind behavior to ignore lid-close events instead of suspending on battery power.

Changes

Cohort / File(s) Summary
Power Management Configuration
named-hosts/matic/default.nix
Added udev rule to force touchpad I2C HID device power control to "on" preventing autosuspend; changed logind HandleLidSwitch from conditional suspend (on battery) to "ignore" for both battery and AC scenarios.

Possibly related PRs

Poem

🐰 A sleepy touchpad needs a gentle nudge,
To stay awake through power's budge,
The lid now whispers "ignore" instead,
No more rude suspends to send to bed! ✨

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and specifically summarizes the main fix: preventing powertop autosuspend on the touchpad for idle detection purposes.
Description check ✅ Passed The description provides comprehensive details about the issue, root cause, the fix (udev rule and logind changes), and a clear test plan, all directly related to the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/touchpad-idle-detection

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a udev rule to the NixOS configuration for the 'matic' host to disable power management autosuspend for a specific i2c touchpad, ensuring idle detection works correctly on battery. A review comment identifies a likely issue with the device matching logic, noting that the current rule targets a child device name rather than the i2c device itself, and suggests a more robust rule using the kernel name and handling both 'add' and 'change' actions.

KERNEL=="event*", ATTRS{name}=="keyd virtual keyboard", GROUP="input", MODE:="0660"
KERNEL=="event*", ATTRS{name}=="keyd virtual pointer", GROUP="input", MODE:="0660"
# Prevent powertop autosuspend on touchpad so idle detection works on battery
ACTION=="add", SUBSYSTEM=="i2c", DRIVERS=="i2c_hid_acpi", ATTRS{name}=="PIXA3854:00 093A:0274", ATTR{power/control}="on"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The udev rule as written is unlikely to match the intended device. ATTRS{name} searches the device and its parents, but "PIXA3854:00 093A:0274" is typically the name of the child input device, not the i2c device itself. To correctly target the i2c device (where power/control is located for powertop tuning), you should match the i2c device directly using its kernel name. Additionally, using ACTION=="add|change" is more robust to ensure the setting is applied if the device state is updated or if powertop runs later in the boot sequence.

          ACTION=="add|change", SUBSYSTEM=="i2c", KERNEL=="i2c-PIXA3854:00", ATTR{power/control}="on"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to keep the PIXA3854 touchpad from being autosuspended (as triggered by powertop --auto-tune) so Hyprland/hypridle continues receiving touchpad input events on battery and doesn’t falsely trigger idle actions.

Changes:

  • Add a udev rule that sets the touchpad power/control to on for the PIXA3854 i2c-hid device.
  • Change systemd-logind lid-close handling to ignore lid close (previously suspended on battery).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# Prevent powertop autosuspend on touchpad so idle detection works on battery
ACTION=="add", SUBSYSTEM=="i2c", DRIVERS=="i2c_hid_acpi", ATTRS{name}=="PIXA3854:00 093A:0274", ATTR{power/control}="on"
'';

Copilot AI Apr 2, 2026

Copy link

Choose a reason for hiding this comment

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

This udev rule will only apply when the device is added. With powerManagement.powertop.enable = true, the powertop systemd unit typically runs later during boot and may set power/control back to auto, overriding this rule and leaving the original issue unfixed. Consider enforcing power/control=on after powertop runs (e.g., a dedicated oneshot systemd service After=powertop.service/WantedBy=multi-user.target, and optionally also on resume) or disabling powertop autotuning for this host if you rely on consistent input wake events.

Suggested change
# Ensure touchpad stays out of autosuspend even after powertop autotuning
systemd.services.touchpad-power-control = {
description = "Keep PIXA3854 touchpad power/control set to on for reliable idle detection";
wantedBy = [ "multi-user.target" ];
after = [ "powertop.service" ];
serviceConfig = {
Type = "oneshot";
ExecStart = ''
${pkgs.runtimeShell} -c 'for d in /sys/bus/i2c/devices/*PIXA3854:00*/power/control; do echo on > "$d" || true; done'
'';
};
};

Copilot uses AI. Check for mistakes.
Comment on lines +246 to +247
# Ignore lid close on both battery and AC — let hypridle's idle timer handle suspension
services.logind.settings.Login.HandleLidSwitch = "ignore";

Copilot AI Apr 2, 2026

Copy link

Choose a reason for hiding this comment

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

This changes lid-close behavior on battery from suspend to ignore, which is a significant behavioral change (risk of the machine staying on in a bag) and isn’t mentioned in the PR description/root-cause writeup. If intentional, please document the rationale in the PR description (or an in-file comment explaining why this host should ignore lid close on battery) so reviewers/users understand the tradeoff.

Copilot uses AI. Check for mistakes.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 1 file

@mesa-dot-dev

mesa-dot-dev Bot commented Apr 2, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Adds a udev rule to prevent powertop --auto-tune from autosuspending the PIXA3854 touchpad, which fixes hypridle's false idle detection on battery.

What changed?

  • Added a udev rule to keep the touchpad power control as on, overriding powertop --auto-tune's default auto setting.
  • This change ensures touchpad events are always registered by Hyprland, resolving issues with hypridle not detecting input and causing unwanted screen dimming, locking, or suspension.

Description generated by Mesa. Update settings

@mesa-dot-dev

mesa-dot-dev Bot commented Apr 2, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Adds udev rule to keep touchpad power control as on, preventing powertop --auto-tune from enabling autosuspend on the PIXA3854 touchpad. Fixes hypridle not detecting mouse/touchpad input on battery, causing false idle triggers (screen dim, lock, suspend) even during active use.

What changed?

  • Added udev rule to keep touchpad power control as on.

Description generated by Mesa. Update settings

@shunkakinoki
shunkakinoki merged commit 95a00aa into main Apr 3, 2026
38 checks passed
@shunkakinoki
shunkakinoki deleted the fix/touchpad-idle-detection branch April 3, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants