This is great. Thanks for sharing.
@griffman I looked to install the wakeonlan script and got back:
I've no ideas how to fix the error(s).
Data deleted for privacy.
Ah ha, yes I am, so that made it so much easier to install. My thanks.
Now to integrate that into the system
One last question, when connected remotely if one chooses to 'Sleep' the Mac the remote connection wakes it up again immediately, and ideas if that behaviour can be stopped?
That is I want to disconnect and let the Mac go to Sleep.
I'm not sure I understand this—are you trying to sleep it while connected, then disconnect? You can't do that, obviously. But you can set the machine to automatically sleep after a short idle period, which should work. That's how one of my two remote Macs works; the other has to be awake 24x7.
-rob.
You could also run a macro or script on the remote Mac that triggered sleep after a short delay, to give you time to disconnect. Or send a sleep command over Remote Scripting or (passwordless) ssh
after quitting Screen Sharing.
What I haven't been able to do, which is slightly perplexing, is use an eppc
remote call from a KM AppleScript action -- works fine in Script Editor, does nothing in KM.
Yep that is what I thought. It's actually my wife's Mac I connect to, to do work on it etc.
I did connect last night, and she muttered that when she went in to check on something in her office (some 2 hours later) the screen was on.
I did try to send it to sleep but as you say this failed.
Her Mac is set the same as mine:
Which should turn the screen off.......
Hmm, this is getting beyond my feeble abilities again
Keyboard Maestro has a Display Sleep command—I actually send that to the Mac that has to on 24x7 as the last command in the macro. It won't sleep the machine, but the screen goes dark.
-rob.
Right I'll look into this. You have it in the same Macro so in effect it connects remotely and then turns the display off locally?
Yea; it's the last action in the macro on the remote Mac after everything else I need to do is done.
-rob.
If you turn on "Remote Scripting" on the remote Mac (System Settings -> General -> Sharing) then, on your Mac, you could run the following in Script Editor:
tell application "Finder" of machine "eppc://username:password@remoteAddress" to sleep
...changing username
and password
for account credentials for the remote machine, remoteAddress
for its address (you can use the Bonjour .local
address, as you did for screen sharing).
Or you could make an AppleScript app on the remote machine, put it in the dock, and remember to run it before you close the screen sharing session:
on run()
delay 5 -- gives you 5 seconds to close the connection
tell application "Finder" to sleep
end
If you've got KM installed on the remote Mac you could make a "sleep" macro, again with a pause to give yourself time to disconnect:
...which you can then "Export as a Trigger File...". Put the Trigger File on the remote machine's Desktop or on its Dock and use that to run the macro just before you disconnect.
You could turn on KM's web server on the remote machine, give that "sleep" macro a public web trigger, then call it from your machine at the end of a "close screen sharing" macro:
And I'm sure there's a bunch more ways depending on what you have (or can make) available on the remote machine.
Right, my thanks, I'll do some experimenting with the options you've given me. No KBM on my wife's Mac alas.
The next step before I go into that is the WakeOnLan scripting. I've got the IP address of her LAN port, and the MAC address of it. We're on network 192.168.1.x, with subnet 255.255.255.0, but networking is my weak area so I'm still trying to work out what command I need to issue is (and then how to send it).
Once is working (so I can always connect) then I'll look closely art the sleep options.
All the advice is very much appreciated guys
Have you actually tried without? For me, I can simply open the vnc
connection and doing that will (eventually!) wake the target machine, no more work required.
Mutter, it turns out my good lady is / was using the Amphetamine app to keep her Mac awake (a left over from when she was working from home) and that I think was stopping the screen sleeping.
So I've asked her:
- To turn on the 'Remote Scripting' option
- Turn off Amphetamine
And we'll see how it goes! Fingers crossed!
Alas even with those changes made I get:
So I'm going to have to work out how to get WakeonLan triggering for the machine.
I've had some success quickly moving the cursor "outside" of the remote control window right after selecting Sleep, then carefully closing the window with the mouse (since cmd-w would be intercepted by the remote desktop and wake it back up)
I'll try that next time I can connect. So far I'm not able to get the remote connection to the Mac to succeed so I do need to work out how to send the correct wakeonlan command.
To close this out I managed to work out the correct format for 'WakeOnLan' and if I send that command prior to doing the remote connection I do seem to manage to connect (so far anyway).
When I'm ready to terminate the remote connection I run a Shortcut on the iMac which waits for 30 seconds and then turns the screen off.
So yeah I guess we're all good (so far). Thanks to everyone for the help!