diff options
author | Patrick Chilton <chpatrick@gmail.com> | 2019-06-25 23:58:20 +0200 |
---|---|---|
committer | worldofpeace <worldofpeace@protonmail.ch> | 2019-08-06 18:08:21 -0400 |
commit | 7c854aa974670b5ff1f707ad80ff0ccaf1d54b9f (patch) | |
tree | 572b59b0a6e77d1baf64cd663d54322b76b5fe94 | |
parent | c3cc7034e2562b110cd12192e0f390ad25cb5dbe (diff) | |
download | nixlib-7c854aa974670b5ff1f707ad80ff0ccaf1d54b9f.tar nixlib-7c854aa974670b5ff1f707ad80ff0ccaf1d54b9f.tar.gz nixlib-7c854aa974670b5ff1f707ad80ff0ccaf1d54b9f.tar.bz2 nixlib-7c854aa974670b5ff1f707ad80ff0ccaf1d54b9f.tar.lz nixlib-7c854aa974670b5ff1f707ad80ff0ccaf1d54b9f.tar.xz nixlib-7c854aa974670b5ff1f707ad80ff0ccaf1d54b9f.tar.zst nixlib-7c854aa974670b5ff1f707ad80ff0ccaf1d54b9f.zip |
nixos/gdm: add autoSuspend option
-rw-r--r-- | nixos/modules/services/x11/display-managers/gdm.nix | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/nixos/modules/services/x11/display-managers/gdm.nix b/nixos/modules/services/x11/display-managers/gdm.nix index ff4b91923e02..3f1669d08516 100644 --- a/nixos/modules/services/x11/display-managers/gdm.nix +++ b/nixos/modules/services/x11/display-managers/gdm.nix @@ -96,6 +96,14 @@ in type = types.bool; }; + autoSuspend = mkOption { + default = true; + description = '' + Suspend the machine after inactivity. + ''; + type = types.bool; + }; + }; }; @@ -176,10 +184,40 @@ in systemd.user.services.dbus.wantedBy = [ "default.target" ]; - programs.dconf.profiles.gdm = pkgs.writeText "dconf-gdm-profile" '' - system-db:local - ${gdm}/share/dconf/profile/gdm - ''; + programs.dconf.profiles.gdm = + let + customDconf = pkgs.writeTextFile { + name = "gdm-dconf"; + destination = "/dconf/gdm-custom"; + text = '' + ${optionalString (!cfg.gdm.autoSuspend) '' + [org/gnome/settings-daemon/plugins/power] + sleep-inactive-ac-type='nothing' + sleep-inactive-battery-type='nothing' + sleep-inactive-ac-timeout=0 + sleep-inactive-battery-timeout=0 + ''} + ''; + }; + + customDconfDb = pkgs.stdenv.mkDerivation { + name = "gdm-dconf-db"; + buildCommand = '' + ${pkgs.gnome3.dconf}/bin/dconf compile $out ${customDconf}/dconf + ''; + }; + in pkgs.stdenv.mkDerivation { + name = "dconf-gdm-profile"; + buildCommand = '' + # Check that the GDM profile starts with what we expect. + if [ $(head -n 1 ${gdm}/share/dconf/profile/gdm) != "user-db:user" ]; then + echo "GDM dconf profile changed, please update gdm.nix" + exit 1 + fi + # Insert our custom DB behind it. + sed '2ifile-db:${customDconfDb}' ${gdm}/share/dconf/profile/gdm > $out + ''; + }; # Use AutomaticLogin if delay is zero, because it's immediate. # Otherwise with TimedLogin with zero seconds the prompt is still |