Close desktop safety gaps
This commit is contained in:
@@ -14,6 +14,9 @@ settings="$config_home/panama/settings.json"
|
||||
generated="$state_home/panama/hyprlock.conf"
|
||||
hyprlock_log="$fixture/hyprlock.log"
|
||||
theme_helper="$repo_dir/config/dot/quickshell/scripts/panama-theme-apps"
|
||||
shipped_wallpaper="$fixture_home/Pictures/Wallpapers/faroe_islands.jpg"
|
||||
global_wallpaper="$fixture_home/Pictures/Wallpapers/global.jpg"
|
||||
portrait_wallpaper="$fixture_home/Pictures/Wallpapers/portrait.jpg"
|
||||
|
||||
fail() {
|
||||
printf 'lock screen helper contract: %s\n' "$1" >&2
|
||||
@@ -28,6 +31,9 @@ trap cleanup EXIT
|
||||
|
||||
mkdir -p "$fixture_home/Pictures/Wallpapers" "$config_home/panama" \
|
||||
"$config_home/hypr" "$state_home" "$test_bin"
|
||||
printf 'shipped wallpaper\n' >"$shipped_wallpaper"
|
||||
printf 'global wallpaper\n' >"$global_wallpaper"
|
||||
printf 'portrait wallpaper\n' >"$portrait_wallpaper"
|
||||
cp "$repo_dir/config/dot/hypr/hyprlock.conf.template" \
|
||||
"$config_home/hypr/hyprlock.conf.template"
|
||||
HOME="$fixture_home" XDG_CONFIG_HOME="$config_home" \
|
||||
@@ -131,19 +137,38 @@ write_settings '{"accentName":"not-a-real-accent","colorScheme":"dark"}'
|
||||
run_helper generate
|
||||
rg -Fq 'outer_color = rgba(130, 170, 255, 0.9)' "$generated" || fail 'an unknown accent name did not fall back to blue'
|
||||
|
||||
write_settings '{
|
||||
"lockBackgroundMode":"wallpaper",
|
||||
"wallpaperMode":"per-monitor",
|
||||
"wallpaperPath":"/images/global.jpg",
|
||||
"wallpaperPerMonitor":{"DP-2":"/images/portrait.jpg"}
|
||||
}'
|
||||
write_settings "$(jq -n \
|
||||
--arg global "$global_wallpaper" \
|
||||
--arg portrait "$portrait_wallpaper" \
|
||||
'{lockBackgroundMode:"wallpaper",wallpaperMode:"per-monitor",wallpaperPath:$global,wallpaperPerMonitor:{"DP-2":$portrait}}')"
|
||||
run_helper generate
|
||||
[[ "$(rg -c '^background \{' "$generated")" -eq 2 ]] || fail 'wallpaper mode did not create one block per output'
|
||||
awk '/^background \{/{block++} block==1 && /monitor = DP-2/{monitor=1} block==1 && /path = \/images\/portrait.jpg/{path=1} END{exit !(monitor && path)}' "$generated" \
|
||||
awk -v path="$portrait_wallpaper" '/^background \{/{block++} block==1 && /monitor = DP-2/{monitor=1} block==1 && index($0, "path = " path){path_seen=1} END{exit !(monitor && path_seen)}' "$generated" \
|
||||
|| fail 'per-monitor wallpaper was not used for DP-2'
|
||||
awk '/^background \{/{block++} block==2 && /monitor = HDMI-A-1/{monitor=1} block==2 && /path = \/images\/global.jpg/{path=1} END{exit !(monitor && path)}' "$generated" \
|
||||
awk -v path="$global_wallpaper" '/^background \{/{block++} block==2 && /monitor = HDMI-A-1/{monitor=1} block==2 && index($0, "path = " path){path_seen=1} END{exit !(monitor && path_seen)}' "$generated" \
|
||||
|| fail 'missing monitor assignment did not fall back to the global wallpaper'
|
||||
|
||||
# A selected but unreadable image never reaches hyprlock. One bounded warning
|
||||
# covers both missing global and per-monitor choices while the shipped image is
|
||||
# still readable.
|
||||
write_settings "$(jq -n \
|
||||
--arg missing "$fixture/missing.jpg" \
|
||||
'{lockBackgroundMode:"wallpaper",wallpaperMode:"per-monitor",wallpaperPath:$missing,wallpaperPerMonitor:{"DP-2":$missing}}')"
|
||||
run_helper generate
|
||||
[[ "$(rg -c "path = $shipped_wallpaper" "$generated")" -eq 2 ]] \
|
||||
|| fail 'missing selected wallpapers did not fall back to the readable shipped image'
|
||||
jq -e '.generated == true and .fallback == false
|
||||
and .error == "One or more lock-screen wallpapers were unavailable; a safe fallback is in use."' \
|
||||
<<<"$(run_helper status)" >/dev/null \
|
||||
|| fail 'missing wallpaper fallback did not report one bounded warning'
|
||||
|
||||
# If no image is readable, screenshot is the only background source that
|
||||
# hyprlock can still render safely.
|
||||
rm -f "$shipped_wallpaper"
|
||||
run_helper generate
|
||||
[[ "$(rg -c 'path = screenshot' "$generated")" -eq 2 ]] \
|
||||
|| fail 'missing wallpapers without the shipped image did not fall back to screenshots'
|
||||
|
||||
write_settings '{"lockBackgroundMode":"screenshot","lockShowClock":true,"lockShowDate":false,"lockShowUser":false,"use24Hour":true}'
|
||||
run_helper generate
|
||||
rg -Fq 'text = cmd[update:1000] date +"%H:%M"' "$generated" || fail '24-hour clock setting was ignored'
|
||||
|
||||
Reference in New Issue
Block a user