Way to remotely restart Finder (or wake-up the desktop) from SSH

findersshterminal

Over the last few months I've found my MacBook Pro is getting increasingly unwilling to wake-up if it's gone to sleep of it's own accord – not when I put it to sleep deliberately, but when the machine is left for a while and it eventually goes to sleep itself.

I usually run it with the lid down, with a mini-DVI-connected 'main' monitor and then a USB-connected 'second' monitor. Sometimes no amount of keypressing, gently tapping the power button, disconnecting the external displays and lifting the laptop lid, plugging in USB devices, inserting and ejecting CDs – no amount of any tricks I've tried will 'wake up' the display even though the machine is running (shares available over the network) and I can SSH in.

I can sudo shutdown -r now on the machine, though obviously that's a bit drastic!. It got me wondering if there was any other terminal command I could use to wake-up the Finder (I guess) – it certainly seems that the desktop has gone to sleep and can't be tricked into waking up.

Can the finder be restarted remotely via SSH? If not the finder, does anyone know of any other terminal means of forcing the machine to completely wake-up and return to it's previous state?

Best Answer

This quits the Finder by sending it the "quit" AppleEvent, which is the same signal the system sends when logging out or restarting via the GUI:

osascript -e 'quit application "Finder"'

I (also) don't think quitting the Finder will fix the wake-from-sleep issue, though.