aboutsummaryrefslogtreecommitdiffstats
path: root/modules/media/screen-recording
diff options
context:
space:
mode:
authorArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-29 02:02:23 +0530
committerArpit Chakladar <arpitchakladar+git@gmail.com>2026-08-29 03:50:32 +0530
commit41bdeb88009dd232808edee9fc0e4ae94358d8d6 (patch)
treec1a41f54e086064dac178ebed24d36ab34087c32 /modules/media/screen-recording
parent530299d97926d45939f831dc3ea5e444d2839d08 (diff)
downloadhome-manager-config-41bdeb88009dd232808edee9fc0e4ae94358d8d6.tar.gz
home-manager-config-41bdeb88009dd232808edee9fc0e4ae94358d8d6.zip
refactor: moving script into modules that makes sense
- instead of collecting all scripts into modules/scripts we are moving them to modules that makes sense (yazi-file-chooser.sh into yazi)
Diffstat (limited to 'modules/media/screen-recording')
-rw-r--r--modules/media/screen-recording/assertions.nix11
-rw-r--r--modules/media/screen-recording/default.nix40
-rw-r--r--modules/media/screen-recording/screen-recording.sh52
-rw-r--r--modules/media/screen-recording/screen-recording.zsh4
4 files changed, 107 insertions, 0 deletions
diff --git a/modules/media/screen-recording/assertions.nix b/modules/media/screen-recording/assertions.nix
new file mode 100644
index 0000000..200d5ea
--- /dev/null
+++ b/modules/media/screen-recording/assertions.nix
@@ -0,0 +1,11 @@
+{ config, ... }:
+[
+ {
+ assertion = !config.media.screen-recording.enable || config.media.slurp.enable;
+ message = "media.screen-recording is enabled but requires `media.slurp.enable`.";
+ }
+ {
+ assertion = !config.media.screen-recording.enable || config.media.wf-recorder.enable;
+ message = "media.screen-recording is enabled but requires `media.wf-recorder.enable`.";
+ }
+]
diff --git a/modules/media/screen-recording/default.nix b/modules/media/screen-recording/default.nix
new file mode 100644
index 0000000..7a68f08
--- /dev/null
+++ b/modules/media/screen-recording/default.nix
@@ -0,0 +1,40 @@
+# Screen recording script using wf-recorder and slurp
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+let
+ inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule;
+ script = mkScriptModule {
+ scope = [ "media" ];
+ 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 = [
+ 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;
+ };
+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/obs.svg;
+ };
+ }
+ ];
+}
diff --git a/modules/media/screen-recording/screen-recording.sh b/modules/media/screen-recording/screen-recording.sh
new file mode 100644
index 0000000..336c32e
--- /dev/null
+++ b/modules/media/screen-recording/screen-recording.sh
@@ -0,0 +1,52 @@
+#!/usr/bin/env bash
+OUT_DIR="$HOME/Videos/Recordings"
+mkdir -p "$OUT_DIR"
+
+# Colors
+GREEN='\033[0;32m'
+YELLOW='\033[1;33m'
+RED='\033[0;31m'
+NC='\033[0m'
+
+# Argument parsing
+SELECT_MODE=false
+while [[ "$#" -gt 0 ]]; do
+ case $1 in
+ -s|--select) SELECT_MODE=true ;;
+ esac
+ shift
+done
+
+# Geometry selection
+GEOMETRY=""
+
+if [ "$SELECT_MODE" = true ]; then
+ if command -v slurp >/dev/null 2>&1; then
+ echo -e "${YELLOW}Select a window or draw a box...${NC}"
+ GEOMETRY=$(slurp)
+
+ if [ -z "$GEOMETRY" ]; then
+ echo "Selection cancelled. Exiting."
+ exit 1
+ fi
+ else
+ echo -e "${RED}Error: 'slurp' not found.${NC} Recording full screen..."
+ sleep 1
+ fi
+fi
+
+# Start recording
+FILENAME="$OUT_DIR/recording-$(date +%Y%m%d-%H%M%S).mp4"
+
+echo -e "${GREEN}Recording started!${NC}"
+echo -e "Press ${YELLOW}'q'${NC} in this terminal to stop."
+echo "File: $FILENAME"
+echo "------------------------------------------------"
+
+if [ -n "$GEOMETRY" ]; then
+ wf-recorder -g "$GEOMETRY" -f "$FILENAME"
+else
+ wf-recorder -f "$FILENAME"
+fi
+
+echo -e "\n${GREEN}Done!${NC} Video saved to $FILENAME"
diff --git a/modules/media/screen-recording/screen-recording.zsh b/modules/media/screen-recording/screen-recording.zsh
new file mode 100644
index 0000000..835ec43
--- /dev/null
+++ b/modules/media/screen-recording/screen-recording.zsh
@@ -0,0 +1,4 @@
+#compdef screen-recording
+
+_arguments \
+ '(-s --select)'{-s,--select}'[Launch slurp to select recording region]'