diff options
Diffstat (limited to 'modules/media/screen-recording')
| -rw-r--r-- | modules/media/screen-recording/default.nix | 74 |
1 files changed, 51 insertions, 23 deletions
diff --git a/modules/media/screen-recording/default.nix b/modules/media/screen-recording/default.nix index 109ed0a..163ee3f 100644 --- a/modules/media/screen-recording/default.nix +++ b/modules/media/screen-recording/default.nix @@ -6,35 +6,63 @@ ... }: let - inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule; - script = mkScriptModule { - scope = [ "media" ]; + screenRecordingScript = pkgs.writeShellApplication { name = "screen-recording"; - path = ./screen-recording.sh; - description = "Screen recording script using wf-recorder and slurp for region selection\nRecords Wayland screen to MP4\nUsage: screen-recording.sh [-s|--select]\n -s, --select Launch slurp to select recording region"; - deps = [ + runtimeInputs = [ pkgs.bash config.media.slurp.package config.media.wf-recorder.package ]; - completion.zsh = builtins.readFile ./screen-recording.zsh; - desktop = { - enable = true; - displayName = "Screen Recording"; - icon = "obs"; - }; - inherit config; + 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 = script.options; - config = lib.mkMerge [ - script.config - { - assertions = import ./assertions.nix { inherit config lib; }; - home.file.".local/share/icons/hicolor/scalable/apps/obs.svg" = { - source = ../../../assets/icons/apps/obs.svg; - }; - } - ]; + 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"; + }; + }; } |
