From 8c62520666e9f60b713e8fbff3b04fd535fcf132 Mon Sep 17 00:00:00 2001 From: obsidrielle <1049617132@qq.com> Date: Wed, 14 May 2025 10:45:01 +0800 Subject: [PATCH] Refactor: consistently use temporary files and mv (atomic operation) --- .config/ags/scripts/color_generation/switchwall.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.config/ags/scripts/color_generation/switchwall.sh b/.config/ags/scripts/color_generation/switchwall.sh index 783288d70..1d295ff48 100755 --- a/.config/ags/scripts/color_generation/switchwall.sh +++ b/.config/ags/scripts/color_generation/switchwall.sh @@ -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" }