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