Update lock and record-window

e128afc215b7e00bae8b955e0dd5bd432d493517
Alexis Sellier committed ago 1 parent 7ae2ff5e
bin/lock +1 -1
1 1
#!/bin/sh
2 2
export XSECURELOCK_AUTH_FOREGROUND_COLOR=aquamarine
3 -
export XSECURELOCK_AUTH_WARNING_COLOR=red
3 +
export XSECURELOCK_AUTH_WARNING_COLOR=aquamarine
4 4
export XSECURELOCK_FONT="monospace:size=12"
5 5
export XSECURELOCK_PASSWORD_PROMPT=asterisks
6 6
export XSECURELOCK_SHOW_HOSTNAME=0
7 7
export XSECURELOCK_SHOW_USERNAME=0
8 8
bin/record-window +37 -42
1 -
#!/bin/sh
2 -
set -e
1 +
#!/usr/bin/env sh
2 +
set -eu
3 3
4 -
unset x y w h
5 -
6 -
FPS=${FPS:-12}
4 +
FPS=${FPS:-16}
7 5
SCALE=${SCALE:-1}
8 -
NAME=${1:-unknown}
9 -
EXT=${2:-webm}
10 -
11 -
if ! command -v xwininfo >/dev/null 2>&1; then
12 -
  printf "fatal: command 'xwininfo' not found"
13 -
  exit 1
14 -
fi
15 -
16 -
ID="$(xwininfo | grep "Window id" | cut -d' ' -f4 -)"
17 -
18 -
# NOTE: To get the active window: `xwininfo -id $(xdotool getactivewindow)`
19 -
20 -
eval $(xwininfo -id "$ID" |
21 -
    sed -n -e "s/^ \+Absolute upper-left X: \+\([0-9]\+\).*/x=\1/p" \
22 -
           -e "s/^ \+Absolute upper-left Y: \+\([0-9]\+\).*/y=\1/p" \
23 -
           -e "s/^ \+Width: \+\([0-9]\+\).*/w=\1/p" \
24 -
           -e "s/^ \+Height: \+\([0-9]\+\).*/h=\1/p" )
25 -
26 -
now="$(date +"%Y%m%d-%H%M%S")"
27 -
tmp="$(mktemp).gif"
28 -
29 -
let x=$x+1
30 -
let y=$y+1
31 -
32 -
OUT="$NAME-$now.$EXT"
33 -
34 -
ffmpeg -v warning \
35 -
       -video_size ${w}x${h} \
36 -
       -framerate $FPS \
37 -
       -f x11grab \
38 -
       -i :0.0+${x},${y} \
39 -
       -vcodec libvpx-vp9 \
40 -
       -b:v 1M \
41 -
       -vf fps=$FPS,scale=iw*$SCALE:ih*$SCALE \
42 -
       "$OUT"
43 -
44 -
echo "saved to '$OUT'"
6 +
CRF=${CRF:-21}
7 +
NAME=${1:-capture}
8 +
DISPLAY=${DISPLAY:-:0.0}
9 +
SLOP_OPTS=${SLOP_OPTS:-}
10 +
11 +
need() {
12 +
  command -v "$1" >/dev/null 2>&1 || {
13 +
    printf "fatal: %s not found\n" "$1"; exit 1;
14 +
  };
15 +
}
16 +
17 +
need slop
18 +
need ffmpeg
19 +
20 +
# Pick region/window: "x y w h"
21 +
set -- $(slop $SLOP_OPTS -f '%x %y %w %h') || { printf "aborted\n"; exit 1; }
22 +
x=$1 y=$2 w=$3 h=$4
23 +
24 +
VF="crop=iw-2:ih-2:1:1,fps=${FPS},scale=trunc(iw*${SCALE}/2)*2:trunc(ih*${SCALE}/2)*2"
25 +
ts=$(date +"%Y%m%d-%H%M%S")
26 +
out="${NAME}-${ts}.webm"
27 +
28 +
printf "recording… to %s (Ctrl-C)\n" "$out"
29 +
30 +
# Run ffmpeg in the foreground so it handles Ctrl-C itself and finalizes cleanly
31 +
exec ffmpeg -v warning \
32 +
  -video_size "${w}x${h}" \
33 +
  -framerate "${FPS}" \
34 +
  -f x11grab -i "${DISPLAY}+${x},${y}" \
35 +
  -vf "${VF}" \
36 +
  -c:v libvpx-vp9 -crf "${CRF}" -b:v 0 \
37 +
  -row-mt 1 -tile-columns 2 -tile-rows 1 \
38 +
  -pix_fmt yuv420p \
39 +
  "${out}"
45 40
46 41
# TIP: convert FILE.gif -strip -coalesce -layers Optimize OPTIMIZED.gif