first commit

This commit is contained in:
2026-05-26 19:25:02 +09:00
commit 972392a192
5 changed files with 131 additions and 0 deletions

29
cam Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/sh
if [ -n "$1" ]; then
out=$1
keep=1
else
out=$(mktemp --suffix=.png)
keep=
fi
conf=$(mktemp)
trap 'rm -f "$conf"; [ -z "$keep" ] && rm -f "$out"' EXIT
printf 's screenshot-to-file "%s" ; quit\n' "$out" > "$conf"
mpv av://v4l2:/dev/video0 \
--demuxer-lavf-format=video4linux2 \
--demuxer-lavf-o=input_format=mjpeg,video_size=1280x720 \
--profile=low-latency \
--force-window=immediate \
--geometry=50%:50% \
--input-conf="$conf" \
--title=cam --osd-msg1="s: snap q: cancel" \
--really-quiet 2>/dev/null
[ -s "$out" ] || exit 0
[ -n "$keep" ] && exit 0
xclip -selection clipboard -t image/png -loops 1 < "$out" &
sleep 0.1

26
camv Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/sh
out=${1:-/tmp/cam-$(date +%Y%m%d-%H%M%S).mp4}
raw=$(mktemp --suffix=.mkv)
conf=$(mktemp)
trap 'rm -f "$conf" "$raw"' EXIT
printf 's set stream-record "%s" ; show-text REC\n' "$raw" > "$conf"
mpv av://v4l2:/dev/video0 \
--demuxer-lavf-format=video4linux2 \
--demuxer-lavf-o=input_format=mjpeg,video_size=640x480 \
--profile=low-latency \
--force-window=immediate \
--geometry=50%:50% \
--input-conf="$conf" \
--title=camv --osd-msg1="s: rec q: stop" \
--really-quiet 2>/dev/null
[ -s "$raw" ] || exit 0
ffmpeg -hide_banner -loglevel fatal -nostdin \
-vaapi_device /dev/dri/renderD128 -i "$raw" \
-vf 'format=nv12,hwupload' \
-c:v h264_vaapi -qp 28 -y "$out"
echo "$out"

26
scr Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
if ! command -v slop >/dev/null; then
echo "scr: slop not found" >&2
exit 1
fi
copy=0
if [ $# -eq 0 ]; then
copy=1
out=$(mktemp --suffix=.png)
else
out=$1
fi
coords=$(slop -f "%x %y %w %h" 2>/dev/null) || exit 1
read x y w h <<<"$coords"
ffmpeg -f x11grab -loglevel error -s ${w}x${h} \
-i ${DISPLAY}+${x},${y} -frames:v 1 -y "$out"
if [ $copy -eq 1 ]; then
xclip -selection clipboard -t image/png -i "$out"
fi
echo "$out"

34
scrv Executable file
View File

@@ -0,0 +1,34 @@
#!/bin/bash
QUALITY=28
if ! command -v slop &> /dev/null
then
echo "slop command not found. Please install slop."
exit 1
fi
if [ -z "$1" ]; then
echo "Usage: $0 <output.mp4>"
exit 1
fi
filename="$1"
echo "Select the desktop area to record."
coords=$(slop -f "%x %y %w %h" 2>/dev/null)
x=$(echo $coords | awk '{print $1}')
y=$(echo $coords | awk '{print $2}')
width=$(echo $coords | awk '{print $3}')
height=$(echo $coords | awk '{print $4}')
width=$((width / 2 * 2))
height=$((height / 2 * 2))
echo "Recording started. Press 'q' to stop recording."
ffmpeg -f x11grab -loglevel quiet -s ${width}x${height} -i ${DISPLAY}+$x,$y \
-c:v libx264 -pix_fmt yuv420p -crf ${QUALITY} -preset ultrafast -f mp4 $filename
echo "Recording stopped."

16
trk Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
# trk — translate English↔Korean, direction picked from input.
if [ $# -gt 0 ]; then
text=$*
else
text=$(cat)
fi
if printf '%s' "$text" | grep -qP '[\x{AC00}-\x{D7A3}\x{3131}-\x{3163}]'; then
pair=ko:en
else
pair=en:ko
fi
exec trans -b "$pair" "$text"