You could do two policies, one with a script as follows:
#!/bin/bash loggedInUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None]); username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + " ");') if [[ -z "$loggedInUser" ]] || [[ "$loggedInUser" == "root" ]]; then jamf policy -event "trigger_of_policy_you_want_to_run" fi exit 0
The other policy would have a custom trigger of "trigger_of_policy_you_want_to_run". So the first policy with script will check for a logged in user, if there is not one, it will execute the other policy.
I was wondering if anybody has setup a "REUSABLE" policy trigger for computers that dont have anybody logged in.
Example a computer lab. I would love to automate the Google Chrome updates with a script, but only Run that policy when no user is logged on.
I was trying to modify the Script above to create something of a "CUSTOM" trigger. that i could reuse for this Chrome update script or for several others.
I guess I am dreaming of a predefined policy trigger That RUNS when computer is not logged on or "IDLE" this way software would be updated in timely manner when the 'computers in the far corner' is not used or rebooted in a long time.
Thank you for all your help,
Alternatively if you have a policy you want to run, say a weekly update check and reboot and the update will not impact the User
#!/bin/sh currentUser=$(stat -f %Su "/dev/console") if [[ "$currentUser" = "root" ]]; then jamf policy -event "trigger_of_policy_you_want_to_run_if_no_user" else jamf policy -event "trigger_of_policy_you_want_to_run_if_a_user_is_logged_in" fi exit 0