From d00bf2cb2d5087164fa509a4f20a2be62a519044 Mon Sep 17 00:00:00 2001 From: sommerfeld Date: Tue, 21 Apr 2026 01:23:18 +0100 Subject: refactor: restructure to chezmoi source state Rename home/ contents to chezmoi naming conventions: - dot_ prefix for dotfiles and dot-dirs - private_dot_ for .gnupg and .ssh directories - private_ for 0600 files (nym.pub) - executable_ for scripts in .local/bin and display-toggle.sh - symlink_ for mimeapps.list symlink --- dot_local/bin/executable_record | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 dot_local/bin/executable_record (limited to 'dot_local/bin/executable_record') diff --git a/dot_local/bin/executable_record b/dot_local/bin/executable_record new file mode 100755 index 0000000..00ac367 --- /dev/null +++ b/dot_local/bin/executable_record @@ -0,0 +1,77 @@ +#!/usr/bin/env sh + +pid_file="/tmp/recordpid" +log_file="/tmp/record.log" + +pid_exists() { + test -r "$pid_file" +} + +is_running() { + if pid_exists; then + ps "$(cat "$pid_file")" >/dev/null 2>&1 || return 1 + else + return 1 + fi +} + +start() { + notify-send -t 500 "Record started!" & + sleep 0.5 + + wf-recorder -f "$HOME/vids/$(date '+%y%m%d-%H%M-%S').mkv" >"$log_file" 2>&1 & + echo "$!" >"$pid_file" +} + +stop() { + pid_exists || exit 1 + pid="$(cat "$pid_file")" + # kill with SIGTERM, allowing finishing touches. + kill "$pid" + # even after SIGTERM, ffmpeg may still run, so SIGKILL it. + sleep 3 + is_running && kill -9 "$pid" + rm -f "$pid_file" + notify-send "Record stopped!" +} + +toggle() { + if is_running; then + echo "Stopping record" + stop + else + echo "Starting record" + start + fi + echo + status +} + +status() { + if is_running; then + echo "Recording with PID $(cat "$pid_file")" + echo "Check the logs at" + echo + echo "$log_file" + echo + else + echo "Record inactive" + fi +} +case "$1" in + start) + start + ;; + stop) + stop + ;; + toggle) + toggle + ;; + status) + status + ;; + *) + toggle + ;; +esac -- cgit v1.2.3-70-g09d2