diff options
| author | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-29 03:45:10 +0530 |
|---|---|---|
| committer | Arpit Chakladar <arpitchakladar+git@gmail.com> | 2026-08-29 03:50:33 +0530 |
| commit | 1a39cf221e3f647df0767c88d89a54e3813e7019 (patch) | |
| tree | b3df1afb0bcc0942a364f267f993ed1a9bfb9434 /modules/media/screen-recording/default.nix | |
| parent | e9e375f5f5263964fe89479a2610081000959774 (diff) | |
| download | home-manager-config-1a39cf221e3f647df0767c88d89a54e3813e7019.tar.gz home-manager-config-1a39cf221e3f647df0767c88d89a54e3813e7019.zip | |
refactor: adding explicit options to enable scripts
- some scripts that are not critical to the functioning of other
options, can be enabled/disabled
Diffstat (limited to 'modules/media/screen-recording/default.nix')
| -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"; + }; + }; } |
