commit 972392a192288fa3733ef7b83cf6a3ac27436b47 Author: Hojun-Cho Date: Tue May 26 19:25:02 2026 +0900 first commit diff --git a/cam b/cam new file mode 100755 index 0000000..d1c8ab5 --- /dev/null +++ b/cam @@ -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 diff --git a/camv b/camv new file mode 100755 index 0000000..5921dcb --- /dev/null +++ b/camv @@ -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" diff --git a/scr b/scr new file mode 100755 index 0000000..8b0d524 --- /dev/null +++ b/scr @@ -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" diff --git a/scrv b/scrv new file mode 100755 index 0000000..cc36fb3 --- /dev/null +++ b/scrv @@ -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 " + 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." diff --git a/trk b/trk new file mode 100755 index 0000000..a466ed2 --- /dev/null +++ b/trk @@ -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"