From 3cec27788e85e3da21654ec6d89c0df2a1384ebf Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 3 Mar 2019 13:33:59 +0100 Subject: [PATCH] transform 'exec' to a 'while' loop to avoid recursion limitations --- README.md | 17 +++++------------ src/xlock | 54 ++++++++++++++++++++++++++++-------------------------- 2 files changed, 33 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index fc4d337..764ef92 100644 --- a/README.md +++ b/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@.path' with `` 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. \ No newline at end of file +To add a key binding or to automate your script lock, simply delete the `/tmp/.unlocked` file. \ No newline at end of file diff --git a/src/xlock b/src/xlock index 5954ed0..63edcd4 100644 --- a/src/xlock +++ b/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; \ No newline at end of file +done; \ No newline at end of file