Professional Web Applications Themes

Is there an API to do this? Is it even possible? - Mac Programming

Hi folks. Got an app, which by its very nature, would be best run with the monitor "unable to sleep" - As in, regardless of the "sleep" settings in the Energy Saver control panel, the monitor and the machine (drives don't matter) never go to sleep as long as the program is running. Now I realize that this is contrary to the usual HIG wisdom of "don't do anything the user doesn't ask for", but at the same time, in the context of this particular application, having the monitor (or the machine itself) go to sleep defeats the entire purpose ...

  1. #1

    Default Is there an API to do this? Is it even possible?



    Hi folks.

    Got an app, which by its very nature, would be best run with the monitor
    "unable to sleep" - As in, regardless of the "sleep" settings in the
    Energy Saver control panel, the monitor and the machine (drives don't
    matter) never go to sleep as long as the program is running.

    Now I realize that this is contrary to the usual HIG wisdom of "don't do
    anything the user doesn't ask for", but at the same time, in the context
    of this particular application, having the monitor (or the machine
    itself) go to sleep defeats the entire purpose of the program, so it's
    time to step outside the "box" that the HIG imposes, I'm thinking.

    What I'd like to do is something like this:

    During app initialization, grab whatever the current Energy Saver
    control panel settings are, save them (within the app), change them to
    the neccesary "monitor and computer never sleep" values, and then do
    whatever it takes to cram those values back into wherever they need to
    be to change the settings. Once that's done, my app runs as usual, only
    the machine and the monitor never sleep. At app shutdown, my plan is to
    retrieve the saved settings, and do whatever is needed to "put things
    back like they were" so that the machine and/or monitor can sleep again
    once my app quits.

    Is there an API (or doentation) that would make this less painful, or
    even possible? If so, I must have missed it.

    Classic (Universal Interfaces/Headers 3.3+) preferred, Carbon (any
    version) considered. Cocoa/"X-native" ideas are untouchable for me - I'm
    working under 9.1, targeting Pre-X machines, hopefully back to system
    7-ish. Nothing says I can't "forget about" pre-8 machines if I
    absolutely have to, although I'd like to try to keep them supported in
    the app if possible, preferably without needing to maintain two branches
    of the code to do it.

    Anybody got any suggestions for me?

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  2. #2

    Default Re: Is there an API to do this? Is it even possible?

    In article <RavYb.1847$sonic.net>,
    Don Bruder <net> wrote:
     

    I really don't see the justification for this. Put up a big message
    somewhere that tells the user in no uncertain terms that if his machine
    goes to sleep then your program is not very useful. A user whose machine
    goes to sleep will be much less annoyed than a user whose machine
    doesn't go to sleep when he was expecting it to, just because he
    happened to have left your app open in the background. This will
    especially annoy portable users who leave their machine on battery
    knowing it will shut off in five minutes, only to come back and see that
    it's dead.

    Maybe if you explain further you could convince me otherwise, but I
    think that a user should have to explicitly decide for himself to make
    the machine never sleep.
    Michael Guest

  3. #3

    Default Re: Is there an API to do this? Is it even possible?

    In article <RavYb.1847$sonic.net>, Don Bruder
    <net> wrote:
     

    I don't recommend that approach for a variety of reasons.

    If this is Carbon, you can call UpdateSystemActivity() in your
    processing loop or from a Carbon timer to keep the machine from
    sleeping. Keep in mind this might P.O. a lot of your customers, esp.
    notebook users, if they are not told you're app will be doing this.
    Chris Guest

  4. #4

    Default Re: Is there an API to do this? Is it even possible?

    I think you probably want to check out the kiosk functions. Here is a
    technote that explains it.

    http://developer.apple.com/technotes/tn2002/tn2062.html

    Hope this helps.

    nlexcom
    Neil Guest

  5. #5

    Default Re: Is there an API to do this? Is it even possible?

    In article <RavYb.1847$sonic.net>,
    Don Bruder <net> wrote:
     

    I definitely don't recommend that. There's way too large a chance of
    ing up the user's preferences. What if your program crashes, or the
    user force quits it? Then they have to reset their preferences manually.

    There's actually an approved way to do this, just search
    developer.apple.com for information about setting up kiosks.


    In article <mail-6B9C12.23493117022004localhost>,
    Michael Ash <com> wrote:
     

    Making the user change their preferences every time they run this
    application is a little silly. There's nothing wrong with keeping the
    machine out of sleep, as long as its clear to the user that this is the
    desired operation.

    Perhaps add a preference to allow the user to let the program keep the
    computer awake? And otherwise just let the computer go to sleep when it
    wants to.

    --
    |\/| /| |2 |<
    mehaase(at)sas(dot)upenn(dot)edu
    Mark Guest

  6. #6

    Default Re: Is there an API to do this? Is it even possible?

    In article <mail-6B9C12.23493117022004localhost>,
    Michael Ash <com> wrote:
     
    >
    > I really don't see the justification for this. Put up a big message
    > somewhere that tells the user in no uncertain terms that if his machine
    > goes to sleep then your program is not very useful. A user whose machine
    > goes to sleep will be much less annoyed than a user whose machine
    > doesn't go to sleep when he was expecting it to, just because he
    > happened to have left your app open in the background.[/ref]

    Not likely - To leave the app running in the background is also
    defeating its purpose. It's a "one-trick pony" that's pointless to run
    at all unless you're looking for its specific "trick", and anyone who's
    going to run this program is likely to be MUCH more upset if the machine
    and/or monitor sleeps and the program's purpose is defeated than if the
    program kills the battery but accomplishes its intended task in the
    process.
     

    Well, although a notebook with appropriate system software CAN run this
    program, doing so from battery, especially if one is expecting the
    computer to (effectively) shut down in some short period of time, is
    again a very good way to render the program useless. Due to the
    program's intended function, which I'm not currently at liberty to
    discuss in more specific terms than I've used so far due to NDA, I'd
    suspect that failure to accomplish its task would be much more annoying
    than having dead batteries after it DOES perform the intended task.
     

    That's fine and dandy. You're entitled to think what you like, no
    question. But please realize that I didn't ask for your thoughts on
    whether it was advisable. Only if it was doable, and/or if there is an
    API available to make doing it at least slightly less painful than
    dental surgery without anesthesia.

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  7. #7

    Default Re: Is there an API to do this? Is it even possible?

    In article <170220041950304478%net>,
    Chris Baum <net> wrote:
     
    >
    > I don't recommend that approach for a variety of reasons.[/ref]

    I'd be willing ot hear and consider the reasons...
     

    As of right now, it's still "classic", although Carbonizing is a
    possible next step for it.
     

    Well, as I said in another response, trying to run this program on a
    notebook will be possible, but if you expect the machine to effectively
    shut itself down while the program is running, there's not a whole lot
    of point to running the program in the first place. Gawd, sometimes I
    positively *HATE* NDAs... And this is one of those times...

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  8. #8

    Default Re: Is there an API to do this? Is it even possible?

    In article <google.com>,
    com (Neil Alexander) wrote:
     

    It looks as though it would - if I were targeting MacOS X. I'm
    specifically targeting "Pre-X" systems.

    Thanks for trying, at least!

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  9. #9

    Default Re: Is there an API to do this? Is it even possible?

    In article <upenn.edu>,
    Mark Haase <net> wrote:
     
    >
    > I definitely don't recommend that. There's way too large a chance of
    > ing up the user's preferences.[/ref]

    I'm not talking about changing the user's preferences, I'm talking about
    diddling them slightly during the program's execution.
     

    An occurrence which I believe would be much less annoying (and
    potentially, much less devastating in terms of possible problems coming
    about due to the program not accomplishing its intended purpose) than
    the failure of the program to achieve its intended purpose.
     

    So far, the material on kiosks I'm seeing doesn't appear to touch on
    what I'm looking at doing, or is aimed specifically at MacOS X, while
    I'm working specifically with Pre-X systems.
     
    >
    > Making the user change their preferences every time they run this
    > application is a little silly.[/ref]

    Which is *EXACTLY* why I'm asking the question(s) I'm asking. As a user
    of the progam, I'm finding it obnoxious that I need to either
    reconfigure my prefs to disallow sleep before running it, then again
    after quitting to re-enable sleeping, or always run the machine set up
    to never sleep. This is a bit of ridiculous drudgery that's exactly the
    sort of thing a computer is supposed to take care of for you! It
    shouldn't be neccesary to jump through a bunch of hoops before getting
    the functionality of the program - it should "just work". As of right
    now, there are hoops to be jumped thorugh, and I want them eliminated.
    The program is *SUPPOSED* to be "double click it and forget it until it
    does what it's intended to do", with no "thinking" being needed by the
    user. Having to remember to reset preferences before and after running
    it (due to the program's nature, and the situations where it's intended
    to be run, asking the user to remember *ANYTHING* other than "run this
    program" is a certifiable "Bad Idea(TM)" - trust me on this...) destroys
    the intended "so simple even a lobotomized chimp can use it
    successfully" operation.
     

    That's the "ultimate solution" - Indeed, it's the exact concept I have
    in mind for the program's final incarnation - but first, I have to
    establish whether or not what I'm looking for *CAN* be done. Until I do
    that, there's not a lot of point in worrying about giving the user a
    preference to set in order to (dis)allow such behavior.

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  10. #10

    Default Re: Is there an API to do this? Is it even possible?

    In article <kTHYb.1978$sonic.net>,
    Don Bruder <net> wrote:
     

    Is the Energy Saver control panel scriptable? If so, you should be able
    to write an AppleScript wrapper that changes the prefs and starts up
    your application.

    --
    Barry Margolin, mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    Barry Guest

  11. #11

    Default Re: Is there an API to do this? Is it even possible?

    In article <JwHYb.1975$sonic.net>, Don Bruder
    <net> wrote:
     
    >
    > As of right now, it's still "classic", although Carbonizing is a
    > possible next step for it.[/ref]


    OK, well if you check the universal headers, you'd see that
    UpdateSystemActivity() requires nothing more than CarbonLib 1.0 which
    means you can go back to OS 8.6 with this one.

    Just let me know which app this is so I never intall it on my
    Powerbook. :)
    Chris Guest

  12. #12

    Default Re: Is there an API to do this? Is it even possible?

    In article <180220040914586680%net>,
    Chris Baum <net> wrote:
     
    > >
    > > As of right now, it's still "classic", although Carbonizing is a
    > > possible next step for it.[/ref]
    >
    >
    > OK, well if you check the universal headers, you'd see that
    > UpdateSystemActivity() requires nothing more than CarbonLib 1.0 which
    > means you can go back to OS 8.6 with this one.
    >
    > Just let me know which app this is so I never intall it on my
    > Powerbook. :)[/ref]

    <chuckle>

    Well, if/when it gets to the point where I'm allowed to talk about it/it
    sees the light of day, I believe that you (and all the other folks
    aboard the "Don't Do That, It's Evil" train) will easily be able to
    see/understand why, in this particular case, it's a "Good Idea(TM)" to
    do what I'm trying to do with it.

    Honest... I do understand that HIG is there for a reason. And I almost
    always try to code to it unless there's a compelling reason not to. I
    also understand that there are situations that can't be adequately
    addressed by HIG and its mandates. This little project is one of the few
    I've run across where tossing HIG out the window is not only a good
    idea, but practically mandatory.

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  13. #13

    Default Re: Is there an API to do this? Is it even possible?

    In article <O2MYb.2003$sonic.net>,
    Don Bruder <net> wrote: 

    See http://developer.apple.com/technotes/tn/tn1086.html

    The tech note is listed as "retired", but it may work on the systems you're
    interested in. It will _NOT_ work on MacOS X, and if you need MacOS X
    support you're going to have to have two different methods for doing
    it.
    --
    Matthew T. Russotto net
    "Extremism in defense of liberty is no vice, and moderation in pursuit
    of justice is no virtue." But extreme restriction of liberty in pursuit of
    a modi of security is a very expensive vice.
    Matthew Guest

  14. #14

    Default Re: Is there an API to do this? Is it even possible?

    In article <net>,
    speakeasy.net (Matthew Russotto) wrote:
     
    >
    > See http://developer.apple.com/technotes/tn/tn1086.html
    >
    > The tech note is listed as "retired", but it may work on the systems you're
    > interested in. It will _NOT_ work on MacOS X, and if you need MacOS X
    > support you're going to have to have two different methods for doing
    > it.[/ref]

    At first glance, this note appears to be just what I'm looking for. But
    as I just said, that's "at first glance" - I'm obviously going to need
    to do some reading to find out if it's truly as promising as it looks
    (which, as of right now, is *VERY* promising indeed!) before I try
    coding to it. Many thanks, Matt!

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  15. #15

    Default Re: Is there an API to do this? Is it even possible?

    In article <ash.giganews.com>,
    Barry Margolin <mit.edu> wrote:
     
    >
    > Is the Energy Saver control panel scriptable? If so, you should be
    > able to write an AppleScript wrapper that changes the prefs and
    > starts up your application.[/ref]

    What I can't figure out is what kind of program requires the user to
    look at the monitor until the program finishes executing.

    --
    Never play strip tarot.
    Michelle Guest

  16. #16

    Default Re: Is there an API to do this? Is it even possible?

    In article <kTHYb.1978$sonic.net>,
    Don Bruder <net> wrote:
     

    please define "diddle" without using the word "change" or any
    synonyms...yeah, thats what i thought

    --
    |\/| /| |2 |<
    mehaase(at)sas(dot)upenn(dot)edu
    Mark Guest

  17. #17

    Default Re: Is there an API to do this? Is it even possible?

    In article <west.cox.net>,
    Michelle Steiner <org> wrote:
     
    > >
    > > Is the Energy Saver control panel scriptable? If so, you should be
    > > able to write an AppleScript wrapper that changes the prefs and
    > > starts up your application.[/ref]
    >
    > What I can't figure out is what kind of program requires the user to
    > look at the monitor until the program finishes executing.[/ref]

    There is no requirement that the user look at the monitor - just a
    requirement that the user *BE ABLE* to look at the monitor (and see
    something more meaningful than a black screen) *WITHOUT NEEDING TO TOUCH
    THE COMPUTER*. Perhaps the computer is located behind a plate of glass,
    physically inaccesible. Perhaps the user is working on the other side of
    the room. Perhaps the user is watching the screen through a webcam, or
    on a closed-circuit TV system. Perhaps the user is just plain too lazy
    to reach over and jiggle the mouse. Any number of reasons. The reason
    doesn't matter, though. The program needs to display constantly changing
    data, and the user needs to have that data be visible *AT ANY TIME* he
    happens to look at it, with no need for any kind of action on his part
    other than that of pointing his eyes at the screen.

    And for Barry: No - as far as I can figure out, the Energy Saver control
    panel isn't scriptable beyond the grossest level of functionality. As in:

    tell application "Finder"
    select file "Energy Saver" of folder "blah-blah-blah:etc:etc:etc"
    open Selection
    end tell

    seems to be about as elaborate a script as is possible for the ES
    Control Panel. That was one of my first thoughts going into this
    project, actually. Unfortunately, it was also one of the first thoughts
    that got pitched in the trash as totally useless.

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  18. #18

    Default Re: Is there an API to do this? Is it even possible?

    In article <upenn.edu>,
    Mark Haase <net> wrote:
     
    >
    > please define "diddle" without using the word "change" or any
    > synonyms...yeah, thats what i thought[/ref]

    So it's a change to the user prefs if I read the prefs, make a copy,
    alter the copy to match what I need, use that during the duration of my
    run, then restore things to the way I found them after the run ends?

    OK, if you say so.

    Meanwhile, it looks as though Matt has supplied the information I need
    to do what I'm trying to do, and not only is it possible, it was even
    (GASP!) Officially Supported By Apple before X came on the scene and
    obsoleted it! What a concept! Even *APPLE INC* thinks that what I'm
    trying to do should be possible, and provides a way to do it. But since
    X is available, and therefore, everything from "Pre-X" days is obsolete
    junk, the doentation for how to do it has been semi-buried.

    Fortunately, Matt knew how/where to find it and pointed me at it.

    --
    Don Bruder - net <--- Preferred Email - SpamAssassinated.
    Hate SPAM? See <http://www.spamassassin.org> for some seriously great info.
    I will choose a path that's clear: I will choose Free Will! - N. Peart
    Fly trap info pages: <http://www.sonic.net/~dakidd/Horses/FlyTrap/index.html>
    Don Guest

  19. #19

    Default Re: Is there an API to do this? Is it even possible?

    In article <pwPYb.2035$sonic.net>,
    Don Bruder <net> wrote:
     

    Here is a hack that might work, if the info in that tech note doesn't
    help.

    I believe that the energy control panel has a setting not to put the
    system to sleep if the serial port is active. Have the user make a
    one-time setting to turn on this feature and have your program
    periodically access the serial port.

    --
    Never play strip tarot.
    Michelle Guest

  20. #20

    Default Re: Is there an API to do this? Is it even possible?

    In article <pwPYb.2035$sonic.net>,
    Don Bruder <net> wrote:
     

    OK, here's another idea. Can you adopt the technology used by keyboard
    macro extensions?

    --
    Barry Margolin, mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    Barry Guest

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139