transform 'exec' to a 'while' loop to avoid recursion limitations
This commit is contained in:
parent
60080cb2f7
commit
3cec27788e
17
README.md
17
README.md
|
@ -1,9 +1,8 @@
|
|||
# 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 be attempted, they won't succeed !
|
||||
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.
|
||||
|
||||
|
||||
### Installation
|
||||
|
@ -12,15 +11,9 @@ Requirements :
|
|||
- i3lock
|
||||
- [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
|
||||
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.
|
||||
|
||||
|
||||
|
||||
### Security issues
|
||||
|
||||
Killin the `i3lock` process does not remove the locker.
|
||||
To add a key binding or to automate your script lock, simply delete the `/tmp/.unlocked` file.
|
54
src/xlock
54
src/xlock
|
@ -1,37 +1,39 @@
|
|||
#!/bin/bash
|
||||
screenshot_f="/tmp/.lock.screenshot.png";
|
||||
unlock_f="/tmp/.unlocked";
|
||||
log_b="0";
|
||||
|
||||
# if lock file -> exit
|
||||
if [ -f "$unlock_f" ]; then
|
||||
exit 0;
|
||||
fi;
|
||||
while true; do
|
||||
|
||||
# if lock file -> exit
|
||||
if [ -f "$unlock_f" ]; then
|
||||
exit 0;
|
||||
fi;
|
||||
|
||||
|
||||
# take screenshot (if not exists)
|
||||
if [ ! -f $screenshot_f ]; then
|
||||
scrot $screenshot_f;
|
||||
fi;
|
||||
# take screenshot (if not exists)
|
||||
if [ ! -f $screenshot_f ]; then
|
||||
scrot $screenshot_f;
|
||||
fi;
|
||||
|
||||
# lock w/ screenshot
|
||||
i3lock -n -u -p default -e -i $screenshot_f;
|
||||
# -n : no fork (does not work with systemd eitherway)
|
||||
# -u : do not display lock indicator
|
||||
# -p default : do not hide mouse pointer
|
||||
# -e : ignore empty passwords
|
||||
# lock w/ screenshot
|
||||
i3lock -n -u -p default -e -i $screenshot_f;
|
||||
# -n : no fork (does not work with systemd eitherway)
|
||||
# -u : do not display lock indicator
|
||||
# -p default : do not hide mouse pointer
|
||||
# -e : ignore empty passwords
|
||||
|
||||
# if 'i3lock' has been killed or has error
|
||||
if [ "$?" -ne 0 ]; then
|
||||
# if 'i3lock' has been killed or has error
|
||||
if [ "$?" -ne 0 ]; then
|
||||
# re-lock
|
||||
continue;
|
||||
fi;
|
||||
|
||||
# create lock file
|
||||
touch $unlock_f;
|
||||
chmod o=rwx $unlock_f;
|
||||
|
||||
# re-lock
|
||||
exec $0;
|
||||
exit 0;
|
||||
fi;
|
||||
# remove screenshot
|
||||
rm -f $screenshot_f;
|
||||
|
||||
# create lock file
|
||||
touch $unlock_f;
|
||||
chmod o=rwx $unlock_f;
|
||||
|
||||
# remove screenshot
|
||||
rm -f $screenshot_f;
|
||||
done;
|
Loading…
Reference in New Issue