diff --git a/README.md b/README.md index 06e7095..37e9749 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,6 @@ Requirements : run `./install.sh` ; note that you need sudo permissions. ### How to use -The whole wrapper interfaces through a simple file at `/tmp/.unlocked`. To lock your screen, simply delete this file. After the install the service 'xlock@USER.path' with `USER` being the user that launched the install. To start it `systemctl start xlock@USER.path`, at the install it is enabled by default, thus it is launched when you boot. +The whole wrapper interfaces through a random file at `/tmp/RANDOM.xlock`. To lock your screen, simply delete this file. After the install the service 'xlock@USER.path' with `USER` being the user that launched the install. To start it `systemctl start xlock@USER.path`, at the install it is enabled by default, thus it is launched when you boot. -To add a key binding or to automate your script lock, simply delete the `/tmp/.unlocked` file. \ No newline at end of file +To add a key binding or to automate your script lock, simply delete files for the pattern `/tmp/*.xlock`. \ No newline at end of file diff --git a/src/xlock b/src/xlock index 902e7d4..58112f8 100644 --- a/src/xlock +++ b/src/xlock @@ -1,21 +1,18 @@ #!/bin/bash screenshot_f="/tmp/.lock.screenshot.png"; -unlock_f="/tmp/.unlocked"; +unlock_f="`mktemp --suffix=.xlock`"; log_b="0"; +rm "$unlock_f"; + while true; do - # if lock file -> wait for changes - if [ -f "$unlock_f" ]; then + # if lock file -> wait until it is deleted + while [ -f "$unlock_f" ]; do + sleep 1; + done; - # wait while file exists - while [ -f "$unlock_f" ]; do - sleep 1; - done; - - # re-lock when deleted - continue; - fi; + # re-lock when deleted # take screenshot (if not exists)