mirror of
https://github.com/EliasKotlyar/Xiaomi-Dafang-Hacks.git
synced 2025-09-08 07:00:44 +02:00
Remove oldest snaps when save_dir is full & run user motion scripts in background (#647)
* Changed removal logic of saved snaps & run custom motion script in background Oldest files are removed if save_snap directory is full * Update detectionOn.sh
This commit is contained in:
@@ -15,10 +15,12 @@ if [ "$save_snapshot" = true ] ; then
|
||||
if [ ! -d "$save_dir" ]; then
|
||||
mkdir -p "$save_dir"
|
||||
fi
|
||||
# Limit the number of snapshots
|
||||
if [ "$(ls "$save_dir" | wc -l)" -ge "$max_snapshots" ]; then
|
||||
rm -f "$save_dir/$(ls -l "$save_dir" | awk 'NR==2{print $9}')"
|
||||
fi
|
||||
{
|
||||
# Limit the number of snapshots
|
||||
if [ "$(ls "$save_dir" | wc -l)" -ge "$max_snapshots" ]; then
|
||||
rm -f "$save_dir/$(ls -ltr "$save_dir" | awk 'NR==2{print $9}')"
|
||||
fi
|
||||
} &
|
||||
/system/sdcard/bin/getimage > "$save_dir/$filename" &
|
||||
fi
|
||||
|
||||
@@ -52,6 +54,6 @@ fi
|
||||
for i in /system/sdcard/config/userscripts/motiondetection/*; do
|
||||
if [ -x "$i" ]; then
|
||||
echo "Running: $i on"
|
||||
$i on
|
||||
$i on &
|
||||
fi
|
||||
done
|
||||
|
Reference in New Issue
Block a user