feat: add scripts to view themes and take their screenshots

This commit is contained in:
javalsai 2025-06-13 15:40:05 +02:00
parent 7d92c4dd2c
commit 891d6f4783
Signed by: javalsai
SSH Key Fingerprint: SHA256:3G83yKhBUWVABVX/vPWH88xnK4+ptMtHkZGCRXD4Mk8
2 changed files with 75 additions and 0 deletions

57
themes/take-screenshots.sh Executable file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env bash
set -e
MYSELF=$(realpath "$0")
MYDIR=$(dirname "$MYSELF")
COLS=60
ROWS=35
if [[ -z "$IM_FLOATING" ]]; then
# 12 pts ≈ 16 px
exec hyprctl dispatch exec \
"[float; size $((COLS*16)) $((ROWS*16))]" \
"kitty --override font_size=12.0 --override background_opacity=1 --override cursor_trail=0 --override cursor_shape=beam --override cursor_blink_interval=0 bash -c 'cd \"$PWD\" && IM_FLOATING=1 LIDM_PATH=\"$LIDM_PATH\" \"$MYSELF\"'"
fi
LIDM_PATH=${LIDM_PATH:-$(command which lidm)}
echo "Using '$LIDM_PATH'"
[[ -e "$LIDM_PATH" ]] || {
echo "'$LIDM_PATH' is not executable" >&2;
sleep 2;
exit 1;
}
echo "Press enter when the window is clearly visible and nothing in the way"
echo "ONLY use this script if you are on hyprland and a \"normal\" kitty config"
echo "AND make sure you have rg, jq, grim, gifski and maybe a few more"
read
BG=$(rg '^background ' ~/.config/kitty/kitty.conf | cut -d'#' -f2)
printf '\033]4;0;rgb:%s\007' "${BG:0:2}/${BG:2:2}/${BG:4:2}"
PRAD=$(hyprctl getoption decoration:rounding | rg int | cut -d' ' -f2)
hyprctl keyword decoration:rounding 0
for theme in "$MYDIR"/*.ini; do
tty=$(tty)
(LIDM_CONF="$theme" "$LIDM_PATH" <"$tty" || :)&
LIDM_PID=$!
sleep .2
GEOMETRY=$(
hyprctl -j activewindow | \
jq -r '(.at[0]|tostring) + "," + (.at[1]|tostring) + " " + (.size[0]|tostring) + "x" + (.size[1]|tostring)'
)
grim -g "$GEOMETRY" - > "$MYDIR/screenshots/$(basename "$theme" | cut -d. -f1).png"
kill $LIDM_PID
sleep .1
done
gifski \
-Q 100 --fps 2 \
-W $((COLS*16)) \
-o "$MYDIR/../assets/media/lidm.gif" \
"$MYDIR"/screenshots/*.png
printf '\033]104\007'
hyprctl keyword decoration:rounding "$PRAD"

18
themes/view.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -e
MYSELF=$(realpath "$0")
MYDIR=$(dirname "$MYSELF")
LIDM_PATH=${LIDM_PATH:-$(command which lidm)}
echo "Using '$LIDM_PATH'"
[[ -e "$LIDM_PATH" ]] || { echo "'$LIDM_PATH' is not executable" >&2; exit 1; }
echo "Press \`Ctrl + C\` once you are done viewing the theme"
sleep 3
for theme in "$MYDIR/"*.ini; do
LIDM_CONF="$theme" "$LIDM_PATH" || :
echo "That was '$(basename "$theme")'"
sleep 2 || :
done