diff --git a/README.md b/README.md index 764ef92..06e7095 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,7 @@ `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. - +Even if one finds out how to kill the `i3lock` process or the `xlock` one, it won't unlock your screen. ### Installation diff --git a/install.sh b/install.sh index fab964f..bf555ac 100755 --- a/install.sh +++ b/install.sh @@ -11,11 +11,15 @@ sudo cp "$local_d/src/xlock" "$bin_d/xlock"; sudo chmod +x "$bin_d/xlock"; # copy systemd files -printf "(2) copying systemd units\n"; +printf "(2) copying systemd daemon\n"; sudo cp $local_d/systemd/* "$systemd_d"; # enable path printf "(3) enabling systemd watcher\n"; -sudo systemctl enable "xlock@$user.path" > /dev/null 2>&1; +sudo systemctl enable "xlock@$user.service" > /dev/null 2>&1; +# sudo systemctl enable "xlock@$user.path" > /dev/null 2>&1; + +# reload systemd if not first install +sudo systemctl daemon-reload; printf "\n . install sucessful\n" \ No newline at end of file diff --git a/src/xlock b/src/xlock index 63edcd4..902e7d4 100644 --- a/src/xlock +++ b/src/xlock @@ -5,9 +5,16 @@ log_b="0"; while true; do - # if lock file -> exit + # if lock file -> wait for changes if [ -f "$unlock_f" ]; then - exit 0; + + # wait while file exists + while [ -f "$unlock_f" ]; do + sleep 1; + done; + + # re-lock when deleted + continue; fi; diff --git a/systemd/xlock@.path b/systemd/xlock@.path deleted file mode 100644 index bf3101c..0000000 --- a/systemd/xlock@.path +++ /dev/null @@ -1,9 +0,0 @@ -[Unit] -Description=Locker lock file watcher - -[Path] -PathModified=/tmp -Unit=xlock@%i.service - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/systemd/xlock@.service b/systemd/xlock@.service index e49399f..7cd9f25 100644 --- a/systemd/xlock@.service +++ b/systemd/xlock@.service @@ -1,12 +1,15 @@ [Unit] Description=Locker daemon +# allows infinite restarts +StartLimitIntervalSec=0 [Service] -Type=oneshot -RemainAfterExit=false +Type=simple User=%i Group=%i +Restart=always + Environment="DISPLAY=:0" Environment="XAUTHORITY=/home/%i/.Xauthority" ExecStart=/usr/sbin/xlock \ No newline at end of file