a_freyer wrote:If you are only waiting 10 minutes after boot (not login, or otherwise) then you can do this:
- Code: Select all
if (all) of the following conditions are met for (the file or folder being matched)
passes shell script (embedded script)
... your other matching criteria ...
Do the following to the matched file or folder:
...
Embedded line:
- Code: Select all
/usr/bin/uptime | grep -Eoce "up [0-9]{1} min" -e "sec"
This quick and dirty little script tests the output of
uptime (stats since last boot) by looking for a 1-digit number between
"up " and
" min" or, alternately the word
"sec". The return is either 1 (for an uptime of 1-9 mins or 0-59 secs) or 0 otherwise.
However, note that Hazel returns a MATCH for a zero output, and that's what we have here - we want Hazel to continue testing other conditions only when the system has been booted for more then 10 minutes.
Brilliant Idea! I finally sorted it today.
Your embedded needed a little modification:
Since Hazel works with not 0 output but 0 exit code on shell script which means when the grep actually found something so I just added -v to your line for grep to alternate the result.
Means find nothing for first 10 minutes and then find 1 count which result in successful match for Hazel.
/usr/bin/uptime | grep
-v -Eoce "up [0-9]{1} min" -e "sec"
So here we sorted the rule to not - match for first 10 minutes, but then the second problem:
Something has to tigger Hazel after 10 minutes to actually scan Folder X again to now find a match.
So I used the logonhook in mac to run another shell script which just sleeps for first 10 minutes and then
modifies "off" file date-modified attribute just after 10 minutes.
This kicks in Hazel to scan the folder again and boom, a match is found!
And full security system runs then.
So FYI the sequence of events is as follows-
When I want the Security System to Lock my Macbook:-System Boots
- Hazel does routine scan on reboot to folder X -- Result: No Match, as Grep did not find a match
- Hazel Sleeps
- In the mean time, Logonhook kicked in a shell script which is sleeping for 10 minutes
- In 10th minute , the sleeping script touches file "off" in folder X and modifies it's date to current time.
- This kicks in Hazel to rescan Folder X, and this time Match is found as grep condition satisfied
- Which kicks in the mega script:-
Mega script -
-Run your security system script, which will take pictures and snapshots and network info and save them to dropbox, then,
-I added some script to change my account password.
-Set Volume to 6 (Full)
-Say a creative message- something like, you don't seems to be "Your name" therefore I am locking this system. Please Contact "your name"
-Lock the account
When I want the Security System to not run- I just change the file name from off to on in the first 10 minutes.
When I want the Security System to run on demand remotely- I just change the file name remotely because it's on dropbox

Thanks for all your help!
