diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-31 09:32:10 +0100 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-31 09:32:10 +0100 |
| commit | ea405da5bcb491dcb8f0b3b35f19841cfe9dce8a (patch) | |
| tree | d156ff80a905095452aa0a92014f8100e66ac66b /tests/wallp.bats | |
| parent | 845e6d3f393811bdc78833c9457d9768e685e572 (diff) | |
| download | wallp-ea405da5bcb491dcb8f0b3b35f19841cfe9dce8a.tar.gz wallp-ea405da5bcb491dcb8f0b3b35f19841cfe9dce8a.zip | |
feat: copy the vertical wallpaper to a phone
With PHONE_V set, every change of the vertical wallpaper is copied to
that path, a fixed name inside a folder Syncthing shares with a phone,
where a Termux loop applies it (script in the README). A copy, not a
symlink, because Syncthing does not follow links. It is built in
~/.cache/wallp and moved into place, so Syncthing never sees a partial
file.
PHONE_SIZE (WxH) crops it to the phone screen, centred, with magick, as
swaybg's fill does: Android otherwise scales a landscape image to the
screen height and shows its left edge. A stamp of source and size skips
an image already copied, so a --restore at login does not make the phone
reapply it. Unset PHONE_V does nothing.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/wallp.bats')
| -rw-r--r-- | tests/wallp.bats | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/wallp.bats b/tests/wallp.bats index 56f3d54..8a092d4 100644 --- a/tests/wallp.bats +++ b/tests/wallp.bats @@ -286,3 +286,52 @@ EOF run require_bins [ "$status" -eq 0 ] } + +@test "parse_conf reads optional PHONE_V and expands tilde" { + conf="$HOME/c.conf" + printf '%s\n' 'PHONE_V=~/sync/phone.png' 'PHONE_SIZE=1440x3120' > "$conf" + parse_conf "$conf" + [ "$CONF_PHONE_V" = "$HOME/sync/phone.png" ] + [ "$CONF_PHONE_SIZE" = "1440x3120" ] +} + +@test "sync_phone copies the vertical wallpaper to PHONE_V" { + printf 'img' > "$HOME/v.png" + mkdir -p "$HOME/.config/wallp" + printf '%s\n' "$HOME/v.png" > "$HOME/.config/wallp/wall_v" + CONF_PHONE_V="$HOME/sync/phone.png" + sync_phone + cmp -s "$HOME/v.png" "$HOME/sync/phone.png" +} + +@test "sync_phone skips a source it already copied" { + printf 'img' > "$HOME/v.png" + mkdir -p "$HOME/.config/wallp" + printf '%s\n' "$HOME/v.png" > "$HOME/.config/wallp/wall_v" + CONF_PHONE_V="$HOME/sync/phone.png" + sync_phone + touch -d '2000-01-01' "$HOME/sync/phone.png" + sync_phone + [ "$(stat -c %Y "$HOME/sync/phone.png")" = "$(date -d 2000-01-01 +%s)" ] +} + +@test "sync_phone crops to PHONE_SIZE, centred" { + magick -size 400x100 xc:red -fill blue -draw 'rectangle 180,0 219,99' "$HOME/v.png" + mkdir -p "$HOME/.config/wallp" + printf '%s\n' "$HOME/v.png" > "$HOME/.config/wallp/wall_v" + CONF_PHONE_V="$HOME/sync/phone.png" + CONF_PHONE_SIZE="20x50" + sync_phone + [ "$(magick identify -format '%wx%h' "$HOME/sync/phone.png")" = "20x50" ] + [ "$(magick "$HOME/sync/phone.png" -format '%[hex:p{10,25}]' info:)" = "0000FF" ] +} + +@test "sync_phone does nothing when PHONE_V is unset" { + printf 'img' > "$HOME/v.png" + mkdir -p "$HOME/.config/wallp" + printf '%s\n' "$HOME/v.png" > "$HOME/.config/wallp/wall_v" + CONF_PHONE_V="" + run sync_phone + [ "$status" -eq 0 ] + [ ! -e "$HOME/sync" ] +} |
