Refactor: consistently use temporary files and mv (atomic operation)

This commit is contained in:
obsidrielle
2025-05-14 10:45:01 +08:00
parent a544f09114
commit 8c62520666
@@ -27,7 +27,7 @@ kill_existing_mpvpaper() {
create_restore_script() {
local video_path=$1
cat > "$RESTORE_SCRIPT" << EOF
cat > "$RESTORE_SCRIPT.tmp" << EOF
#!/bin/bash
# Generated by switchwall.sh - Don't modify it by yourself.
# Time: $(date)
@@ -40,6 +40,7 @@ for monitor in \$(hyprctl monitors -j | jq -r '.[] | .name'); do
done
EOF
mv "$RESTORE_SCRIPT.tmp" $RESTORE_SCRIPT
chmod +x "$RESTORE_SCRIPT"
}