Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 380d6bbff137
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2f22bbe1500d
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on May 9, 2017

  1. Copy the full SHA
    9d1db32 View commit details

Commits on May 19, 2017

  1. Merge pull request #25578 from Ma27/module/xautolock

    services.xserver.xautolock: add module
    Mic92 authored May 19, 2017
    Copy the full SHA
    2f22bbe View commit details
Showing with 73 additions and 0 deletions.
  1. +1 −0 nixos/modules/module-list.nix
  2. +72 −0 nixos/modules/services/x11/xautolock.nix
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Original file line number Diff line number Diff line change
@@ -614,6 +614,7 @@
./services/x11/window-managers/windowlab.nix
./services/x11/window-managers/wmii.nix
./services/x11/window-managers/xmonad.nix
./services/x11/xautolock.nix
./services/x11/xbanish.nix
./services/x11/xfs.nix
./services/x11/xserver.nix
72 changes: 72 additions & 0 deletions nixos/modules/services/x11/xautolock.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{ config, lib, pkgs, ... }:

with lib;

let
cfg = config.services.xserver.xautolock;
in
{
options = {
services.xserver.xautolock = {
enable = mkEnableOption "xautolock";
enableNotifier = mkEnableOption "xautolock.notify" // {
description = ''
Whether to enable the notifier feature of xautolock.
This publishes a notification before the autolock.
'';
};

time = mkOption {
default = 15;
type = types.int;

description = ''
Idle time to wait until xautolock locks the computer.
'';
};

locker = mkOption {
default = "xlock"; # default according to `man xautolock`
example = "i3lock -i /path/to/img";
type = types.string;

description = ''
The script to use when locking the computer.
'';
};

notify = mkOption {
default = 10;
type = types.int;

description = ''
Time (in seconds) before the actual lock when the notification about the pending lock should be published.
'';
};

notifier = mkOption {
default = "notify-send 'Locking in 10 seconds'";
type = types.string;

description = ''
Notification script to be used to warn about the pending autolock.
'';
};
};
};

config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ xautolock ];

services.xserver.displayManager.sessionCommands = with builtins; with pkgs; ''
${xautolock}/bin/xautolock \
${concatStringsSep " \\\n" ([
"-time ${toString(cfg.time)}"
"-locker ${cfg.locker}"
] ++ optional cfg.enableNotifier (concatStringsSep " " [
"-notify ${toString(cfg.notify)}"
"-notifier \"${cfg.notifier}\""
]))} &
'';
};
}