From e77257e756527f6fe7209ecdf27239d5dd5f6d36 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sun, 2 Jun 2024 20:53:46 +0800 Subject: fixed sleep 10 prerequirement, fixed cleanup() --- idle.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/idle.sh b/idle.sh index 50ac312..a83376d 100755 --- a/idle.sh +++ b/idle.sh @@ -25,10 +25,9 @@ fi function cleanup() { /sbin/echo "Cleaning up..." - sudo /sbin/rm -f $lockpath/$lockfile || /sbin/echo "Failed removing lock file at $lockpath/$lockfile" - sudo /sbin/rm -f $lockpath/$pidfile || /sbin/echo "Failed removing PID file at $lockpath/$pidfile" - sudo /sbin/rm -f $lockpath/$disablelockfile || /sbin/echo "Failed removing disable lock file at $lockpath/$disablelockfile" + sudo /sbin/rm -rf $lockpath || /sbin/echo "Failed removing locks at $lockpath" /sbin/echo "Exiting..." + exit 0 } trap cleanup SIGINT SIGTERM @@ -111,8 +110,9 @@ if [ "$1" ]; then if [[ "$(xprintidle)" -gt $IDLETIME && ! -f $lockpath/$lockfile && $1 ]]; then # Changed from 600000 (10 minutes) to 3600000 (1 hour) idle continue - else + elif [[ ! -f $lockpath/$lockfile && $1 ]]; then sleep 10 + continue fi if [[ "$(xprintidle)" -le $IDLEBACKTIME && -f $lockpath/$lockfile ]]; then stopidle -- cgit v1.2.3