don-alvarez / munki

Automatically exported from code.google.com/p/munki
Other
0 stars 0 forks source link

FEATURE REQUEST: wake the screen when munki installer or MunkiStatus runs #11

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I was thinking that it could be useful to have munki wake up the sleeping 
screen while it runs, at least when munki starts installing something and when 
MunkiStatus.app launches in GUI userspace.

Usually a keyboard press wakes up the screen?

Sort of empty keypress (this emulates ctrl-only keypress) can be sent using 
applescript:
/usr/bin/osascript -e 'tell application "System Events"' -e 'key code "" using 
control down' -e 'end tell'

But I guess in this case it would be cleaner to use standard Cocoa frameworks 
for that (though I do not know how...)

Original issue reported on code.google.com by miq...@gmail.com on 21 Jul 2010 at 8:36

GoogleCodeExporter commented 8 years ago
I'll look and see if there _is_ a Cocoa framework that does this.  Do you have 
an example of another app that does this sort of thing?

Original comment by gregnea...@mac.com on 21 Jul 2010 at 8:39

GoogleCodeExporter commented 8 years ago
Umm, you mean by using Cocoa or some other methods?

Not that I know at this moment, that applescript-hackish-thingy has worked for 
me.

I am not sure what that old iHook could do, it probably does not hurt to look 
at it's source:
http://ihook.cvs.sourceforge.net/viewvc/ihook/ihook/

Original comment by miq...@gmail.com on 21 Jul 2010 at 8:49

GoogleCodeExporter commented 8 years ago
No, any commerical or Apple-supplied app that does this.  I'm wondering if this 
is Apple-sanctioned behavior... If not, there's not likely to be a "native" way 
to do it.

Again this could be handled in a preflight script...

-Greg

Original comment by gregnea...@mac.com on 21 Jul 2010 at 8:58

GoogleCodeExporter commented 8 years ago
This can be achieved by inserting plain-old-applescript in 
/usr/local/munki/updatecheckhelper between sleep and managedsoftwareupdate 
--auto -commands:

sleep $seconds

# send empty keystroke which wakes up the screen and disables screensaver 
running over loginwindow
/usr/bin/osascript -e 'tell application "System Events"' -e 'key code "" using 
control down' -e 'end tell'

/usr/local/munki/managedsoftwareupdate --auto

(This could also be inserted in managedsoftwareupdate to be run on every check 
and install cycle but that is another story...and it could be managed by a 
separate key in ManagedInstalls.plist...yet another to-do-later...)

Original comment by miq...@gmail.com on 22 Aug 2010 at 10:08

GoogleCodeExporter commented 8 years ago
To do this in Carbon, code:

#include <Carbon/Carbon.h>
main() {
    while (1==1) {
        UpdateSystemActivity(OverallAct);
        sleep(30);
    }
}

I think the code speaks for itself, so unless the machine goes to deep sleep 
before 30 seconds has passed this will do the trick I think.

Compile as UB:
cc -arch ppc -o keypressppc keypress.c -framework Carbon
cc -arch i386 -o keypressi386 keypress.c -framework Carbon
lipo keypresspcc keypressi386 -create -o keypress

Original comment by analspr...@gmail.com on 2 Feb 2011 at 9:25

GoogleCodeExporter commented 8 years ago
Thank you very much si...@ifixit.no.

This works, it keeps sends screen lit when it is running.

As this "application" keeps running until it is terminated (while loop is true 
forever) it needs to be killed after munki has run.

Otherwise it will keep system awake as it sends activity message to system 
every 30 seconds.

-MiqViq

Original comment by miq...@gmail.com on 3 Feb 2011 at 12:46

GoogleCodeExporter commented 8 years ago
Yes, I needs to be killed... You could remove the loop and loop it from the 
munki script too.

Original comment by analspr...@gmail.com on 9 Feb 2011 at 9:46