From e2295e396f2f722e7fb45e2df29b84f83f71f304 Mon Sep 17 00:00:00 2001 From: Nathan Gill Date: Tue, 8 Sep 2026 20:15:10 +0100 Subject: [PATCH] fix record output script --- modules/home/natha/mango/default.nix | 2 +- modules/home/natha/mango/record-output.sh | 26 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100755 modules/home/natha/mango/record-output.sh diff --git a/modules/home/natha/mango/default.nix b/modules/home/natha/mango/default.nix index e47e837..5c5379c 100644 --- a/modules/home/natha/mango/default.nix +++ b/modules/home/natha/mango/default.nix @@ -192,7 +192,7 @@ in "ALT,Up,viewtoleft,0" "ALT,Down,viewtoright,0" - "SUPER,c,spawn,/usr/bin/env OUT_DIR=${cfg.recordingsDirectory} ${src}/../sway/helpers/record-output.sh" + "SUPER,c,spawn,/usr/bin/env OUT_DIR=${cfg.recordingsDirectory} ${src}/record-output.sh" "SUPER,s,spawn,/bin/sh -c '${grim} -g \"$(${slurp})\" ${cfg.screenshotDirectory}/Screenshot_$(date +%F_%T).png'" "SUPER+SHIFT,s,spawn,/bin/sh -c '${grim} -g \"$(${slurp})\" - | ${wl-copy}'" diff --git a/modules/home/natha/mango/record-output.sh b/modules/home/natha/mango/record-output.sh new file mode 100755 index 0000000..6906eaa --- /dev/null +++ b/modules/home/natha/mango/record-output.sh @@ -0,0 +1,26 @@ +#!/bin/sh +set -eu + +PID_FILE_PATH="$XDG_RUNTIME_DIR/record_output.pid" + +if [ ! -n "$XDG_RUNTIME_DIR" ]; then + echo "XDG_RUNTIME_DIR empty not set!" + exit 1 +fi + +if [ -f "$PID_FILE_PATH" ]; then + TARGET_PID=$(cat "$PID_FILE_PATH") + + kill -n 2 "$TARGET_PID" || true + waitpid "$TARGET_PID" || true + + rm -f "$PID_FILE_PATH" + exit 0 +fi + +REC="$OUT_DIR/Recording_$(date +%F_%T).mkv" + +nohup wf-recorder --file="$REC" > "$HOME/.wf-recorder.log" 2>&1 & +echo $! > "$PID_FILE_PATH" + +exit 0 -- 2.51.2