transform 'exec' to a 'while' loop to avoid recursion limitations

This commit is contained in:
xdrm-brackets 2019-03-03 13:33:59 +01:00
parent 60080cb2f7
commit 3cec27788e
2 changed files with 33 additions and 38 deletions

View File

@ -1,9 +1,8 @@
# xlock screen locker # xlock screen locker
`xlock` really does nothing, it uses and wraps [`i3lock`](https://github.com/i3/i3lock) into [systemd](https://freedesktop.org/wiki/Software/systemd/) to allow a seamless screen lock. You have as a background the screenshot of your current screen, the mouse pointer works, nothing can happen. You just have to type your password, press enter and here you go. `xlock` really does nothing, it only wraps [`i3lock`](https://github.com/i3/i3lock) screen locker into [systemd](https://freedesktop.org/wiki/Software/systemd/) to allow a seamless screen lock. Your screen stays the same, the mouse pointer works, but you can't do anything. You just have to type your password, press enter and here you go .
Your friends and coworkers can try anything, they won't be able to do anything. Even if they find out how to kill the `i3lock` process, it won't unlock your computer.
Your friends and coworkers can be attempted, they won't succeed !
### Installation ### Installation
@ -12,15 +11,9 @@ Requirements :
- i3lock - i3lock
- [scrot](https://phab.enlightenment.org/diffusion/ESVN/browse/trunk/misc/scrot;35502) - [scrot](https://phab.enlightenment.org/diffusion/ESVN/browse/trunk/misc/scrot;35502)
run `./install.sh` ; you need sudo permissions. run `./install.sh` ; note that you need sudo permissions.
### How to use ### How to use
A lock file is created at '/tmp/.unlocked'. To lock your screen, simply delete this file. After the install the service 'xlock@<user>.path' with `<user>` being your username during install. To start it `systemctl start xlock@user.path`, at the install it is enabled by default, so launched at boot. 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.
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 the `/tmp/.unlocked` file.
### Security issues
Killin the `i3lock` process does not remove the locker.

View File

@ -1,37 +1,39 @@
#!/bin/bash #!/bin/bash
screenshot_f="/tmp/.lock.screenshot.png"; screenshot_f="/tmp/.lock.screenshot.png";
unlock_f="/tmp/.unlocked"; unlock_f="/tmp/.unlocked";
log_b="0";
# if lock file -> exit while true; do
if [ -f "$unlock_f" ]; then
exit 0; # if lock file -> exit
fi; if [ -f "$unlock_f" ]; then
exit 0;
fi;
# take screenshot (if not exists) # take screenshot (if not exists)
if [ ! -f $screenshot_f ]; then if [ ! -f $screenshot_f ]; then
scrot $screenshot_f; scrot $screenshot_f;
fi; fi;
# lock w/ screenshot # lock w/ screenshot
i3lock -n -u -p default -e -i $screenshot_f; i3lock -n -u -p default -e -i $screenshot_f;
# -n : no fork (does not work with systemd eitherway) # -n : no fork (does not work with systemd eitherway)
# -u : do not display lock indicator # -u : do not display lock indicator
# -p default : do not hide mouse pointer # -p default : do not hide mouse pointer
# -e : ignore empty passwords # -e : ignore empty passwords
# if 'i3lock' has been killed or has error # if 'i3lock' has been killed or has error
if [ "$?" -ne 0 ]; then if [ "$?" -ne 0 ]; then
# re-lock
continue;
fi;
# create lock file
touch $unlock_f;
chmod o=rwx $unlock_f;
# re-lock # remove screenshot
exec $0; rm -f $screenshot_f;
exit 0;
fi;
# create lock file done;
touch $unlock_f;
chmod o=rwx $unlock_f;
# remove screenshot
rm -f $screenshot_f;