diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2024-06-02 13:18:14 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2024-06-02 13:18:14 +0800 |
| commit | 1fe503ab6a6c869b71f13a6ec66ca15efedc4cb3 (patch) | |
| tree | bc15d11852d66b89e2e2d8fe0f6d5259e99f8865 /idle.sh | |
| parent | 23bfcb7c49328542294815d06c407b5ca9531651 (diff) | |
removed delay for idle, added cleanup for terminate and SIGINT(removing locks)
Diffstat (limited to 'idle.sh')
| -rwxr-xr-x | idle.sh | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -23,6 +23,16 @@ if [ ! -d $lockpath ]; then sudo /sbin/mkdir -vp $lockpath || /sbin/echo "Failed to create lock path at $lockpath" 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" + /sbin/echo "Exiting..." +} + +trap cleanup SIGINT SIGTERM + function idle() { if [[ -f $lockpath/$disablelockfile ]]; then /sbin/echo "idle: Idle is disabled" @@ -105,7 +115,6 @@ if [ "$1" ]; then stopidle continue else - sleep 1 continue fi fi |
