Stop PC from sleep

I have a nixos box that I am using as an HTPC. It works well except I can’t seem to stop it from going to sleep. It never did this with the previous Linux distro I had on the same hardware so I know I must be missing some configuration somewhere.

I tried setting powerManagement.enable = false; but that doesn’t seemed to have stopped it.

Can anyone point me in the right direction?

1 Like

Are you using GNOME3 desktop? Then you might need this:

  # Disable the GNOME3/GDM auto-suspend feature that cannot be disabled in GUI!
  # If no user is logged in, the machine will power down after 20 minutes.
  systemd.targets.sleep.enable = false;
  systemd.targets.suspend.enable = false;
  systemd.targets.hibernate.enable = false;
  systemd.targets.hybrid-sleep.enable = false;
6 Likes

I am not using Gnome. It is basically launching directly into Kodi using

Still, that box never needs to hibernate or suspend so I will definitely try disabling them via systemd. Thanks for the suggestion!

I have the same issue, but with the Pantheon Desktop Environment instead. Disabling power management also didn’t work for me.

I also have this issue, I installed a Gnome desktop just using the graphical installer because I have a screen attached, but the box is actually a server. When I log into Gnome, I can set the box to never go to sleep using Gnome power management… But this setting is not applied when I don’t login (ie when I reboot and walk away), then the machine goes into standby. So I too need a way to prevent the system from ever sleeping.

The comment further up explains how to disable sleep regardless of whether you’re using gnome or not: Stop PC from sleep - #2 by bjornfor

1 Like

I’m pretty sure this was solved for me by autologinUser.

Can confirm, this works for me (I used the gnome image when installing).

If you disable sleep and hibernation on systemd level, you can encounter problem with GNOME trying to send the machine to sleep and turn on the screen.

Also after disabling them on systemd level, you cannot change GNOME settings in UI

Solved for me with

dconf load / < settings

[org/gnome/settings-daemon/plugins/power]
sleep-inactive-ac-timeout=1800
sleep-inactive-ac-type='nothing'
sleep-inactive-battery-timeout=1800
sleep-inactive-battery-type='suspend'

It’s not a declarative way, but fixes my issue. Feel free to upgrade it.