diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-23 12:42:59 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2025-01-23 12:42:59 +0100 |
commit | 6479dbb2ddd5782747d2cf8c18260de1971ae99f (patch) | |
tree | 981125b040674ba6d68f88c42e1acf41b17fe48c /.local | |
parent | c7faac3480d2c52db7e952f638f7f162fb98eeec (diff) |
scripts update
Diffstat (limited to '.local')
-rwxr-xr-x | .local/share/bin/ccpreview | 44 | ||||
-rwxr-xr-x | .local/share/bin/now | 2 | ||||
-rwxr-xr-x | .local/share/bin/preview | 29 | ||||
-rwxr-xr-x | .local/share/bin/screenrecord | 7 |
4 files changed, 59 insertions, 23 deletions
diff --git a/.local/share/bin/ccpreview b/.local/share/bin/ccpreview index a835ab4..914a6ad 100755 --- a/.local/share/bin/ccpreview +++ b/.local/share/bin/ccpreview @@ -24,33 +24,49 @@ VIDEO_URL="av://v4l2:$VIDEO_DEVICE" RESOLUTION="${WIDTH}x${HEIGHT}" +fork() { + JOBS="$JOBS $( + "$@" > /dev/null 2> /dev/null & + echo $! + )" +} + # set capture card v4l parameters v4l2-ctl --silent --device "$VIDEO_DEVICE" \ --set-parm "$FRAMERATE" \ --set-fmt-video "width=$WIDTH,height=$HEIGHT,pixelformat=MJPG" \ --set-ctrl "brightness=0,contrast=128,saturation=128,hue=0" -# preview window -mpv \ - --msg-level=input=no --no-config --input-conf=/dev/null \ - --no-osc --no-input-default-bindings --pause=no --force-seekable=no \ - \ - --no-cache --untimed --no-correct-pts \ +_mpv() { + fork mpv \ + --quiet --msg-level=input=no \ + --no-config --input-conf=/dev/null \ + --no-osc --no-border \ + --no-input-default-bindings --pause=no --force-seekable=no \ + --cache=no \ + "$@" +} + +# audio preview +_mpv \ --no-demuxer-thread \ - --video-sync=audio \ --audio-buffer=0 \ - --vd-lavc-threads=1 \ --cache-pause=no \ --interpolation=no \ - --video-latency-hacks=yes \ --stream-buffer-size=4k \ - \ - --demuxer-lavf-o-add=fflags=+nobuffer \ - --demuxer-lavf-analyzeduration=0 \ + --profile=low-latency \ + "$AUDIO_URL" + +# video preview +_mpv \ + --untimed --no-correct-pts --no-demuxer-thread \ + --profile=low-latency \ --demuxer-lavf-o-add=input_format=mjpeg \ --demuxer-lavf-o-add=framerate="$FRAMERATE" \ --demuxer-lavf-o-add=resolution="$RESOLUTION" \ --demuxer-lavf-o-add=rw_timeout=30000000 \ - \ - "$VIDEO_URL" --audio-file="$AUDIO_URL" + "$VIDEO_URL" + +sleep infinity +kill -9 -- $JOBS diff --git a/.local/share/bin/now b/.local/share/bin/now deleted file mode 100755 index 8fca44f..0000000 --- a/.local/share/bin/now +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -printf '%s\n' "$(khal --color list now 1h --notstarted --day-format '' --format '({start-time}) {calendar-color}{title}{reset}')" diff --git a/.local/share/bin/preview b/.local/share/bin/preview index 0225848..0ca63a7 100755 --- a/.local/share/bin/preview +++ b/.local/share/bin/preview @@ -1,12 +1,25 @@ #!/bin/sh -[ $# -ne 5 ] && exit 1 -FILE="$1" -WIDTH="$2" -HEIGHT="$3" -POS_X="$4" -POS_Y="$5" +[ -n "$1" ] && FILE="$1" || { + echo "error: no input file" + exit 1 +} +[ -n "$2" ] && WIDTH="$(( "$2" - 3 ))" || WIDTH="$(tput cols)" +[ -n "$3" ] && HEIGHT="$3" || HEIGHT="$(tput lines)" +[ -n "$4" ] && POS_X="$4" || POS_X="0" +[ -n "$5" ] && POS_Y="$5" || POS_Y="0" MIMETYPE="$(file --mime-type -Lb "$FILE")" +EXT="${FILE#*.}" + +[ "$EXT" = "md" ] && [ "$MIMETYPE" = "text/plain" ] && MIMETYPE="application/markdown" + +render_manpage() { + exec groff -T utf8 -m man -rcR=1 -rIN=0 -rLL="${WIDTH}n" << EOF +.nr an-suppress-header-and-footer 1 +.TH +$(cat) +EOF +} case "$MIMETYPE" in image/*) @@ -27,11 +40,15 @@ case "$MIMETYPE" in application/x-tar|\ application/x-bzip|\ application/x-bzip2|\ + application/gzip|\ application/zip|\ application/x-7z-compressed|\ application/vnd.rar) bsdtar -tf "$FILE" ;; + application/markdown) + pandoc --from=gfm --to=man "$FILE" | render_manpage + ;; *) echo "$MIMETYPE" file -b "$FILE" | fold --width="$WIDTH" --spaces diff --git a/.local/share/bin/screenrecord b/.local/share/bin/screenrecord index 52c6e5b..d595cc8 100755 --- a/.local/share/bin/screenrecord +++ b/.local/share/bin/screenrecord @@ -1,3 +1,8 @@ #!/bin/sh -giph -f 60 -s -b 4 -c 255,255,255 "$(date +'%Y-%m-%d_%H-%M-%S.mp4')" +exec giph "$@" \ + --framerate=60 \ + --select \ + --bordersize=4 \ + --color=255,255,255 \ + "$(date +'%Y-%m-%d_%H-%M-%S.mp4')" |