summaryrefslogtreecommitdiffstats
path: root/nixos/modules/programs/bash/undistract-me.nix
blob: 6d42db2c14a2116cb6ad9ba3f8b753408a171d2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.programs.bash.undistractMe;
in
{
  options = {
    programs.bash.undistractMe = {
      enable = lib.mkEnableOption "notifications when long-running terminal commands complete";

      playSound = lib.mkEnableOption "notification sounds when long-running terminal commands complete";

      timeout = lib.mkOption {
        default = 10;
        description = ''
          Number of seconds it would take for a command to be considered long-running.
        '';
        type = lib.types.int;
      };
    };
  };

  config = lib.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 lib.maintainers; [ kira-bruneau ];
  };
}