i am currently trying to write a script that will end all currently active screensharing sessions plus set the mac to sleep withing 10 seconds.
Until now i only got the delayed sleep but not the disconnecting of those active screensharing sessions.
This is the script:
# time in seconds to delay before sleep
set delay_time to 10
display dialog ¬
"Going to sleep in " & delay_time & ¬
" seconds" buttons {"Cancel"} ¬
giving up after delay_time ¬
default button 1
copy the result as list to {buttonpressed}
if the buttonpressed is not "Cancel" then
tell application "Finder" to sleep
end if
Is there a way to tell the mac to disconnect all screensharing sessions?
I also would like to have the seconds count down when displayed in this popup windows (currently you will only see “Going to sleep in 10 seconds” without the 10 changing to 9,8,7…)
# time in seconds to delay before sleep
set delay_time to 10
repeat with i from delay_time to 0 by -1
display dialog "Going to sleep in " & (i as text) & ¬
" seconds" buttons {"Cancel"} ¬
giving up after 1 ¬
default button 1
end repeat
set screenSharingPath to (path to library folder from system domain as text) & "CoreServices:Screen Sharing.app"
quit application screenSharingPath
tell application "Finder" to sleep
Whats not working is the screensharing problem. The thing is that there is no screensharing.app running on the server i connect to. Its just an unknown process in the menubar