summaryrefslogtreecommitdiff
path: root/clearcliphis.sh
diff options
context:
space:
mode:
authorlittleblack111 <jerrylam110209@gmail.com>2023-08-14 12:03:52 +0800
committerlittleblack111 <jerrylam110209@gmail.com>2023-08-14 12:03:52 +0800
commit31929cd6f44ffe7cfb65d992a8541671715c9875 (patch)
tree4ef39ed488cc1e354beb3685863457a0e11f2ee6 /clearcliphis.sh
parent4afee5b56a43050c560303e028b1014fdd0732ff (diff)
updated
Diffstat (limited to 'clearcliphis.sh')
-rwxr-xr-xclearcliphis.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/clearcliphis.sh b/clearcliphis.sh
new file mode 100755
index 0000000..001ba88
--- /dev/null
+++ b/clearcliphis.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# Set the directory path
+directory="$XDG_CONFIG_HOME/clipmenu.6.system"
+
+# Calculate the current timestamp
+current_timestamp=$(date +%s)
+
+# Iterate over each file in the directory
+for file in "$directory"/*; do
+ # Check if the file exists and isn't lock*
+ if [ -f "$file" ] && [[ "$file" != "lock" ]] && [[ "$file" != "session_lock" ]]; then
+ # Get the file's last modification timestamp
+ timestamp=$(stat -c %Y "$file")
+
+ # Calculate the difference in seconds between the current timestamp and the file's timestamp
+ time_diff=$((current_timestamp - timestamp))
+
+ # Calculate the number of seconds in a month (30 days)
+ month_in_seconds=$((30 * 24 * 60 * 60))
+
+ # Check if the file exists longer than a month
+ if [ "$time_diff" -gt "$month_in_seconds" ]; then
+ # Delete the file
+ rm -v "$file"
+ echo "Deleted file: '$file'"
+ fi
+ fi
+done