From e59b8b0c37f08f6b6a9399b24e9b67d90c9b8436 Mon Sep 17 00:00:00 2001 From: Evan Stoll Date: Sun, 28 Jul 2019 21:41:02 -0400 Subject: [PATCH] numlock: add module This adds an option `xsession.numlock` that enable the Num Lock key when starting a graphical session. Fixes #651 --- modules/misc/numlock.nix | 34 ++++++++++++++++++++++++++++++++++ modules/modules.nix | 1 + 2 files changed, 35 insertions(+) create mode 100644 modules/misc/numlock.nix diff --git a/modules/misc/numlock.nix b/modules/misc/numlock.nix new file mode 100644 index 00000000..df11f22a --- /dev/null +++ b/modules/misc/numlock.nix @@ -0,0 +1,34 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.xsession.numlock; + +in + +{ + options = { + xsession.numlock.enable = mkEnableOption "Num Lock"; + }; + + config = mkIf cfg.enable { + systemd.user.services.numlockx = { + Unit = { + Description = "NumLockX"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Service = { + Type = "oneshot"; + ExecStart = "${pkgs.numlockx}/bin/numlockx"; + }; + + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + }; + }; +} diff --git a/modules/modules.nix b/modules/modules.nix index 03e048e2..1ec06144 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -28,6 +28,7 @@ let (loadModule ./misc/lib.nix { }) (loadModule ./misc/news.nix { }) (loadModule ./misc/nixpkgs.nix { }) + (loadModule ./misc/numlock.nix { condition = hostPlatform.isLinux; }) (loadModule ./misc/pam.nix { }) (loadModule ./misc/qt.nix { }) (loadModule ./misc/submodule-support.nix { })