summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorBenjamin Chausse <benjamin@chausse.xyz>2024-04-12 18:36:52 -0400
committerBenjamin Chausse <benjamin@chausse.xyz>2024-04-12 18:36:52 -0400
commit27b33a3f9e87b9e582041c5740e5f95be43470fc (patch)
tree75ce769f47c2477b370ff14ae5d4cea9cd0ed2ad /.local
parentf0f6df63b64415d4591564c99f42362d1c526265 (diff)
old image previews cleaner script
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/previewclean10
1 files changed, 10 insertions, 0 deletions
diff --git a/.local/bin/previewclean b/.local/bin/previewclean
new file mode 100755
index 0000000..8b0a570
--- /dev/null
+++ b/.local/bin/previewclean
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+threshold="200000" # 200 MB
+previewdir="${XDG_CACHE_HOME:-$HOME/.cache}/lf"
+
+# Check if the total size of the preview directory exceeds the threshold
+# and remove the last viewed file until it doesn't
+while [ "$(du -s "$previewdir" | cut -f1)" -gt "$threshold" ]; do
+ rm -f "$(find "$previewdir" -type f -printf '%T+ %p\n' | sort | head -n1 | cut -d' ' -f2)"
+done