Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions config/hyprland/hypridle.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ listener {
on-resume = hyprctl dispatch dpms on
}

# Suspend after 30 minutes
# Suspend after 30 minutes (only on battery)
listener {
timeout = 1800
on-timeout = systemctl suspend
on-timeout = bash -c 'cat /sys/class/power_supply/AC*/online | grep -q 1 || systemctl suspend'

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.

medium

The command to check for AC power can be simplified by using grep directly on the file, which avoids the need for cat and a pipe. This is slightly more efficient. I've also added 2>/dev/null to suppress potential error messages if the power supply path doesn't exist, making the execution cleaner.

    on-timeout = bash -c 'grep -q 1 /sys/class/power_supply/AC*/online 2>/dev/null || systemctl suspend'

@cubic-dev-ai cubic-dev-ai Bot Mar 17, 2026 •

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.

P2: This AC-power check only matches online=1, but the kernel ABI also allows online=2 for programmable external supplies. On those chargers, the idle action will still suspend while plugged in.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At config/hyprland/hypridle.conf, line 31:

<comment>This AC-power check only matches `online=1`, but the kernel ABI also allows `online=2` for programmable external supplies. On those chargers, the idle action will still suspend while plugged in.</comment>

<file context>
@@ -25,8 +25,8 @@ listener {
 listener {
     timeout = 1800
-    on-timeout = systemctl suspend
+    on-timeout = bash -c 'cat /sys/class/power_supply/AC*/online | grep -q 1 || systemctl suspend'
 }
</file context>
Suggested change
on-timeout = bash -c 'cat /sys/class/power_supply/AC*/online | grep -q 1 || systemctl suspend'
on-timeout = bash -c 'grep -Eq "^(1|2)$" /sys/class/power_supply/AC*/online || systemctl suspend'
Fix with Cubic

}
3 changes: 3 additions & 0 deletions named-hosts/matic/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ inputs.nixpkgs.lib.nixosSystem {

# Power button behavior - lock screen instead of shutdown
services.logind.settings.Login.HandlePowerKey = "lock";
# Ignore lid close — let hypridle's 30-min idle timer handle suspension
services.logind.settings.Login.HandleLidSwitch = "ignore";

@cubic-dev-ai cubic-dev-ai Bot Mar 17, 2026 •

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.

P2: Delegating lid-close handling entirely to hypridle breaks suspend at the greeter/logout path. Since hypridle only runs inside a logged-in Hyprland session, closing the lid before login or after logout will now be ignored and the laptop stays awake.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At named-hosts/matic/default.nix, line 136:

<comment>Delegating lid-close handling entirely to `hypridle` breaks suspend at the greeter/logout path. Since `hypridle` only runs inside a logged-in Hyprland session, closing the lid before login or after logout will now be ignored and the laptop stays awake.</comment>

<file context>
@@ -132,6 +132,9 @@ inputs.nixpkgs.lib.nixosSystem {
         # Power button behavior - lock screen instead of shutdown
         services.logind.settings.Login.HandlePowerKey = "lock";
+        # Ignore lid close — let hypridle's 30-min idle timer handle suspension
+        services.logind.settings.Login.HandleLidSwitch = "ignore";
+        services.logind.settings.Login.HandleLidSwitchExternalPower = "ignore";
 
</file context>
Fix with Cubic

services.logind.settings.Login.HandleLidSwitchExternalPower = "ignore";
Comment on lines +136 to +137

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.

medium

The HandleLidSwitchExternalPower setting is redundant here. According to the logind.conf documentation, if HandleLidSwitchExternalPower is not set, it defaults to the value of HandleLidSwitch. Since you are setting both to ignore, you can safely remove the HandleLidSwitchExternalPower line to make the configuration more concise.

        services.logind.settings.Login.HandleLidSwitch = "ignore";


# Auto timezone (via geolocation)
services.geoclue2.enable = true;
Expand Down
Loading