about summary refs log tree commit diff
path: root/nixos/modules/programs/bash
diff options
context:
space:
mode:
authorKira Bruneau <kira.bruneau@pm.me>2021-05-03 14:25:02 -0400
committerKira Bruneau <kira.bruneau@pm.me>2021-05-03 14:25:02 -0400
commita24d0ab51be678b2ce8c19498c03d48da057ff46 (patch)
tree09663277ec89a012a5177509cf2f6a21ccfa7bc2 /nixos/modules/programs/bash
parent62a78fc36134d6ffcf279d69f213b30c93885c9e (diff)
modules/programs/bash: add support for undistract-me
Diffstat (limited to 'nixos/modules/programs/bash')
-rw-r--r--nixos/modules/programs/bash/undistract-me.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/nixos/modules/programs/bash/undistract-me.nix b/nixos/modules/programs/bash/undistract-me.nix
new file mode 100644
index 0000000000000..378144f598b56
--- /dev/null
+++ b/nixos/modules/programs/bash/undistract-me.nix
@@ -0,0 +1,36 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.programs.bash.undistractMe;
+in
+{
+  options = {
+    programs.bash.undistractMe = {
+      enable = mkEnableOption "notifications when long-running terminal commands complete";
+
+      playSound = mkEnableOption "notification sounds when long-running terminal commands complete";
+
+      timeout = mkOption {
+        default = 10;
+        description = ''
+          Number of seconds it would take for a command to be considered long-running.
+        '';
+        type = types.int;
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    programs.bash.promptPluginInit = ''
+      export LONG_RUNNING_COMMAND_TIMEOUT=${toString cfg.timeout}
+      export UDM_PLAY_SOUND=${if cfg.playSound then "1" else "0"}
+      . "${pkgs.undistract-me}/etc/profile.d/undistract-me.sh"
+    '';
+  };
+
+  meta = {
+    maintainers = with maintainers; [ metadark ];
+  };
+}