buffybox/unl0kr/regenerate-screenshots.sh

105 lines
2 KiB
Bash
Raw Permalink Normal View History

2021-11-14 13:44:06 +01:00
#!/bin/bash
# Change this depending on what device you're generating the screenshots on
fb_res=1920x1080
2024-03-30 12:46:09 +00:00
executable=$1
2021-11-14 13:44:06 +01:00
outdir=screenshots
2022-01-24 20:45:40 +01:00
config=unl0kr-screenshots.conf
root=$(git rev-parse --show-toplevel)
themes_c=$root/shared/themes.c
2021-11-14 13:44:06 +01:00
resolutions=(
# Nokia N900
480x800
800x480
# Samsung Galaxy A3 2015
540x960
960x540
# Samsung Galaxy Tab A 8.0 2015
768x1024
1024x768
# Pine64 PineTab (landscape)
1280x800
# Pine64 PinePhone (landscape)
1440x720
# BQ Aquaris X Pro (landscape)
2022-10-16 14:15:48 +02:00
1920x1080
2021-11-14 13:44:06 +01:00
)
if ! which fbcat > /dev/null 2>&1; then
echo "Error: Could not find fbcat" 1>&2
exit 1
fi
2024-03-30 12:46:09 +00:00
if [[ ! -f $executable || ! -x $executable ]]; then
echo "Error: Could not find executable at $executable" 1>&2
2021-11-14 13:44:06 +01:00
exit 1
fi
2022-01-24 20:45:40 +01:00
function write_config() {
cat << EOF > $config
[general]
animations=true
[keyboard]
autohide=false
layout=de
popovers=true
[textarea]
obscured=true
[theme]
default=$1
2022-10-16 14:15:48 +02:00
[input]
keyboard=true
2022-11-07 20:18:29 +01:00
pointer=false
2022-10-16 14:15:48 +02:00
touchscreen=false
2022-01-24 20:45:40 +01:00
EOF
}
function clean_up() {
2022-01-24 20:45:40 +01:00
rm -f $config
}
trap clean_up EXIT
2022-01-24 20:45:40 +01:00
2021-11-14 13:44:06 +01:00
rm -rf "$outdir"
mkdir "$outdir"
2022-01-24 20:45:40 +01:00
readme="# Unl0kr themes"$'\n'
clear # Blank the screen
while read -r theme; do
2022-01-24 20:45:40 +01:00
write_config $theme
readme="$readme"$'\n'"## $theme"$'\n\n'
2022-10-16 14:15:48 +02:00
for res in ${resolutions[@]}; do
$executable -m "Please enter a password to unlock the root volume" -g $res -C $config &
2021-11-14 13:44:06 +01:00
pid=$!
2023-10-23 21:02:47 +02:00
sleep 3 # Wait for UI to render
2021-11-14 13:44:06 +01:00
fbcat /dev/fb0 > "$outdir/$theme-$res.ppm"
kill -15 $pid
2022-01-24 20:45:40 +01:00
convert \
-size $fb_res \
"$outdir/$theme-$res.ppm" \
-crop $res+0+0 \
"$outdir/$theme-$res.png"
rm "$outdir/$theme-$res.ppm"
2022-01-24 20:45:40 +01:00
readme="$readme<img src=\"$theme-$res.png\" alt=\"$res\" height=\"300\"/>"$'\n'
2022-10-04 20:31:26 +02:00
sleep 1 # Delay to prevent terminal mode set / reset interference
2021-11-14 13:44:06 +01:00
done
done < <(grep "name =" "$themes_c" | grep -o '".*"' | tr -d '"' | sort)
2022-01-24 20:45:40 +01:00
echo -n "$readme" > "$outdir/README.md"