Close desktop safety gaps
This commit is contained in:
@@ -17,8 +17,10 @@ status_file="$state_dir/hyprlock-status.json"
|
||||
fallback="$config_home/hypr/hyprlock.conf"
|
||||
temporary="$generated.tmp.$$"
|
||||
status_temporary="$status_file.tmp.$$"
|
||||
shipped_wallpaper="$HOME/Pictures/Wallpapers/faroe_islands.jpg"
|
||||
|
||||
settings_valid=false
|
||||
wallpaper_warning=""
|
||||
|
||||
cleanup() {
|
||||
rm -f "$temporary" "$status_temporary" 2>/dev/null || true
|
||||
@@ -76,7 +78,23 @@ read_object() {
|
||||
}
|
||||
|
||||
valid_path() {
|
||||
[[ "$1" == /* && "$1" != *","* && "$1" != *$'\n'* ]]
|
||||
[[ "$1" == /* && "$1" != *","* && "$1" != *$'\n'* && -f "$1" && -r "$1" ]]
|
||||
}
|
||||
|
||||
resolve_wallpaper_path() {
|
||||
local candidate="$1"
|
||||
if valid_path "$candidate"; then
|
||||
resolved_wallpaper="$candidate"
|
||||
return
|
||||
fi
|
||||
if [[ -n "$candidate" ]]; then
|
||||
wallpaper_warning="One or more lock-screen wallpapers were unavailable; a safe fallback is in use."
|
||||
fi
|
||||
if valid_path "$shipped_wallpaper"; then
|
||||
resolved_wallpaper="$shipped_wallpaper"
|
||||
else
|
||||
resolved_wallpaper="screenshot"
|
||||
fi
|
||||
}
|
||||
|
||||
# Same 8 named accents as config/Theme.qml's `accents` map (kept in sync by
|
||||
@@ -134,10 +152,9 @@ load_preferences() {
|
||||
wallpaper_mode="$(read_string wallpaperMode single)"
|
||||
[[ "$wallpaper_mode" == single || "$wallpaper_mode" == slideshow || "$wallpaper_mode" == per-monitor ]] \
|
||||
|| wallpaper_mode=single
|
||||
wallpaper_path="$(read_string wallpaperPath '')"
|
||||
if ! valid_path "$wallpaper_path"; then
|
||||
wallpaper_path="$HOME/Pictures/Wallpapers/faroe_islands.jpg"
|
||||
fi
|
||||
wallpaper_warning=""
|
||||
resolve_wallpaper_path "$(read_string wallpaperPath '')"
|
||||
wallpaper_path="$resolved_wallpaper"
|
||||
wallpaper_assignments="$(read_object wallpaperPerMonitor)"
|
||||
|
||||
case "$blur_level" in
|
||||
@@ -218,8 +235,9 @@ emit_backgrounds() {
|
||||
candidate="$(jq -r --arg output "$output" \
|
||||
'if has($output) and (.[$output] | type) == "string" then .[$output] else "" end' \
|
||||
<<<"$wallpaper_assignments" 2>/dev/null || true)"
|
||||
if valid_path "$candidate"; then
|
||||
assigned="$candidate"
|
||||
if [[ -n "$candidate" ]]; then
|
||||
resolve_wallpaper_path "$candidate"
|
||||
assigned="$resolved_wallpaper"
|
||||
fi
|
||||
fi
|
||||
emit_background "$output" "$assigned"
|
||||
@@ -344,7 +362,7 @@ generate() {
|
||||
write_status false "$fallback" true "The lock-screen configuration could not be generated."
|
||||
return 1
|
||||
fi
|
||||
write_status true "$generated" false ""
|
||||
write_status true "$generated" false "$wallpaper_warning"
|
||||
}
|
||||
|
||||
status() {
|
||||
|
||||
Reference in New Issue
Block a user