Posted on 08-08-2018 06:35 AM
Hello,
Does anybody have a solution to have the machine fall asleep whilst not logging out of the currently logged in user?
Posted on 08-08-2018 06:37 AM
Are your Macs encrypted with FileVault 2?
Posted on 08-08-2018 07:26 AM
#!/bin/bash
loggedInUser=$(/usr/bin/python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "
");')
sudo -u "$loggedInUser" osascript -e 'tell app "System Events" to sleep'
Posted on 08-08-2018 08:42 AM
pmset sleepnow
Posted on 08-08-2018 12:44 PM
@ryan.ball Hey Ryan, I gave your script a shot, seems as though it does put the computer to sleep, but still logs the user off at the same time. Any suggestions?
Posted on 08-08-2018 01:20 PM
@Gennaro Is it logging the user out, or is your "Security & Privacy" preference pane in System Preferences set to "Require password immediately after sleep or screen saver begins"?