From c0d9c594c9480bf63fee22b7b4a06e64cbdbbb79 Mon Sep 17 00:00:00 2001 From: Jas Singh Date: Thu, 22 Aug 2024 20:07:18 -0700 Subject: [PATCH] Fix snapshot script (#173) --- services/snapshot.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/services/snapshot.sh b/services/snapshot.sh index 27554aa..3cbaa6d 100755 --- a/services/snapshot.sh +++ b/services/snapshot.sh @@ -5,7 +5,7 @@ outputFile="snapshot_$(date +%Y-%m-%d_%H-%M-%S).png" outputPath="$outputDir/$outputFile" mkdir -p "$outputDir" -mode=$1 +mode=${1:-area} case "$mode" in active) @@ -18,13 +18,14 @@ area) command="grimblast copysave area $outputPath" ;; *) + echo "Invalid option: $mode" echo "Usage: $0 {active|output|area}" exit 1 ;; esac if eval "$command"; then - recentFile=$(ls -t "$outputDir"/snapshot_*.png | head -n 1) + recentFile=$(find "$outputDir" -name 'snapshot_*.png' -printf '%T+ %p\n' | sort -r | head -n 1 | cut -d' ' -f2-) notify-send "Grimblast" "Your snapshot has been saved." \ -i video-x-generic \ -a "Grimblast" \