aboutsummaryrefslogtreecommitdiffstats
path: root/modules/media/screen-recording/default.nix
blob: 67e422c6eda390ee462b9a699eb62b376dc8853a (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# Screen recording script using wf-recorder and slurp
{
  config,
  lib,
  pkgs,
  ...
}:
let
  screenRecordingScript = pkgs.writeShellApplication {
    name = "screen-recording";
    runtimeInputs = [
      config.terminal.bash.package
      config.media.slurp.package
      config.media.wf-recorder.package
    ];
    text = builtins.readFile ./screen-recording.sh;
  };

  screenRecordingCompletion =
    pkgs.runCommand "screen-recording-completion"
      {
        nativeBuildInputs = [ pkgs.installShellFiles ];
      }
      ''
        mkdir -p $out/share/zsh/site-functions
        installShellCompletion zsh --name _screen-recording ${pkgs.writeText "screen-recording.zsh" (builtins.readFile ./screen-recording.zsh)}
      '';

  scriptPkg = pkgs.symlinkJoin {
    name = "screen-recording";
    paths = [
      screenRecordingScript
      screenRecordingCompletion
    ];
    meta = screenRecordingScript.meta or { };
  };
in
{
  options.media.screen-recording = {
    enable = lib.mkEnableOption "Screen recording script using wf-recorder and slurp";

    package = lib.mkOption {
      type = lib.types.package;
      readOnly = true;
      default = scriptPkg;
      description = "The screen-recording script package.";
    };
  };

  config = lib.mkIf config.media.screen-recording.enable {
    home.packages = [ scriptPkg ];

    assertions = import ./assertions.nix { inherit config lib; };

    home.file.".local/share/icons/hicolor/scalable/apps/obs.svg" = {
      source = ../../../assets/icons/apps/obs.svg;
    };

    xdg.desktopEntries.screen-recording = {
      name = "Screen Recording";
      exec = "${lib.getExe config.terminal.kitty.package} --class screen-recording -e ${lib.getExe scriptPkg}";
      icon = "obs";
      categories = [ "Utility" ];
      terminal = false;
      type = "Application";
    };
  };
}