From cba3ba4b3b9be548dd44629fe1a55336ccf3598e Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 24 Mar 2019 16:54:54 +0100 Subject: [PATCH] fix no auto-lock on boot --- src/xlock | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/xlock b/src/xlock index 4f31d43..82ad26f 100644 --- a/src/xlock +++ b/src/xlock @@ -4,13 +4,17 @@ unlock_f="`mktemp --suffix=.xlock`"; log_b="0"; -# lock by default -rm "$unlock_f"; -# automatic unlock if booted less than 2mins ago -onboot=`echo "$(cat /proc/uptime | awk '{print $1}') > 1000;" | bc`; -if [ "$onboot" -gt 0 ]; then - touch "$unlock_f"; + +# returns whether the computer has just booted a few minutes ago +booted(){ + # onboot=`echo "$(cut -d' ' -f1 /proc/uptime) > 1000;" | bc`; + return echo "$(cut -d' ' -f1 /proc/uptime) > 1000;" | bc; +} + +# lock by default (if not just booted) +if [ "$(booted)" -ne 1 ]; then + rm "$unlock_f"; fi; while true; do