update readme + random lock file + cleanup code

This commit is contained in:
xdrm-brackets 2019-03-03 14:13:09 +01:00
parent dd82c8abed
commit 68911239ff
2 changed files with 10 additions and 13 deletions

View File

@ -13,6 +13,6 @@ Requirements :
run `./install.sh` ; note that you need sudo permissions. run `./install.sh` ; note that you need sudo permissions.
### How to use ### 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. To add a key binding or to automate your script lock, simply delete files for the pattern `/tmp/*.xlock`.

View File

@ -1,21 +1,18 @@
#!/bin/bash #!/bin/bash
screenshot_f="/tmp/.lock.screenshot.png"; screenshot_f="/tmp/.lock.screenshot.png";
unlock_f="/tmp/.unlocked"; unlock_f="`mktemp --suffix=.xlock`";
log_b="0"; log_b="0";
rm "$unlock_f";
while true; do while true; do
# if lock file -> wait for changes # if lock file -> wait until it is deleted
if [ -f "$unlock_f" ]; then while [ -f "$unlock_f" ]; do
sleep 1;
done;
# wait while file exists # re-lock when deleted
while [ -f "$unlock_f" ]; do
sleep 1;
done;
# re-lock when deleted
continue;
fi;
# take screenshot (if not exists) # take screenshot (if not exists)