From dd78faaf40862bd1552ec36c41374b527f747284 Mon Sep 17 00:00:00 2001
From: Xiao Pan <gky44px1999@gmail.com>
Date: Fri, 23 Feb 2024 03:08:52 -0800
Subject: Reorganize shell scripts into sh dir, consider in the future fsh will
 have different kinds of files

---
 sh/reco | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100755 sh/reco

(limited to 'sh/reco')

diff --git a/sh/reco b/sh/reco
new file mode 100755
index 0000000..7ee726d
--- /dev/null
+++ b/sh/reco
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# useful urls:
+# https://github.com/LukeSmithxyz/voidrice/blob/master/.local/bin/dmenurecord
+# https://wiki.archlinux.org/title/FFmpeg#Screen_capture
+# https://trac.ffmpeg.org/wiki/Capture/Desktop
+
+infofile="/tmp/recoinfo"
+recodir="$XDG_VIDEOS_DIR/recordings/"
+tmpdir="$recodir/tmp/"
+mkdir -p "$recodir" "$tmpdir"
+
+if [ -e "$infofile" ]; then
+	read -r pid tmpfile < "$infofile"
+	kill "$pid"
+	notify-send 'finish recording, start converting'
+	ffmpeg -i "$tmpfile" "$recodir/$(time-uuid).mkv"
+	notify-send 'finish converting'
+	rm "$tmpfile" "$infofile"
+else
+	tmpfile="$tmpdir/$(time-uuid).mkv"
+	notify-send 'prepare recording'
+	# arch wiki way, no audio, less cpu use during capturing (fast?), large file size, need convert afterward
+	xrectsel '%w %h %x %y' | xargs sh -c 'ffmpeg -y -loglevel quiet -f x11grab -framerate 25 -s "$2x$3" -i "$DISPLAY+$4,$5" -c:v ffvhuff "$1" & echo $!' shell "$tmpfile" | xargs -I {} printf '%s\t%s' '{}' "$tmpfile" > "$infofile"
+	# another way to get subshell ffmpeg child pid
+	#xrectsel '%w %h %x %y' | xargs sh -c 'ffmpeg -y -f x11grab -framerate 25 -s "$2x$3" -i "$DISPLAY+$4,$5" -c:v ffvhuff "$1"' shell "$tmpfile" &
+	#printf '%s\t%s' "$(ps -o pid= --ppid $!)" "$tmpfile" > "$infofile"
+fi
-- 
cgit v1.2.3-70-g09d2