#!/bin/bash # Enable device lock on boot /usr/bin/devicelock-enable # Sleep time 20 --> 3 lines/minute if discharging, not connected to wlan and screen locked while true; do sleep 20 && if lshal | grep -q 'battery.rechargeable.is_charging = true' then > /opt/sec-lock/sec-lock.log elif dbus-send --system --type=method_call --dest="com.nokia.mce" --print-reply "/com/nokia/mce/request" com.nokia.mce.request.get_tklock_mode|awk -F "\"" '/g/ {print $2}' | grep -q 'unlocked' then > /opt/sec-lock/sec-lock.log elif /usr/sbin/iw dev wlan0 link | grep -q 'Connected to' then > /opt/sec-lock/sec-lock.log else echo "Screen locked..." >> /opt/sec-lock/sec-lock.log fi # Check if sec-lock.log is full (3 lines/minute --> 30 minutes = 90 lines) if [ 90 -eq "$(wc -l < /opt/sec-lock/sec-lock.log)" ] then > /opt/sec-lock/sec-lock.log && /usr/bin/devicelock-enable fi; done