Background Program?

Discussion in 'Mac Programming' started by ArtOfWarfare, Sep 15, 2011.

  1. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #1
    I have a concept for an extremely simple Mac application, but I have no idea how to make it. I'd like it to be a program that runs invisibly in the background and detects when a key is pressed and released. When the key is pressed, it should lock a file, when the key is released, it should unlock the file.

    That's all.

    The issue is, I've never made an application that runs completely without a UI. I don't even want the menubar to change at all.

    Also, not particularly important as I'm content with just running the application on my own computer and those of a few friends that want it, but do you think Apple would allow such a program on the App Store? It's not a virus or male ware or anything of that nature.
     
  2. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #2
    So you would need to keep holding the key in it's down position for the file to remained locked? Seems utterly pointless, what are you trying to do exactly?
    Can you define what you mean by lock, and also what type of files you are talking about. You might be able to use automator, since you can assign keys to run automator actions.
     
  3. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #3
    I'm sorry I'm so vague, but I feel like my idea is easy to monetize via the Mac App Store.

    I've found documents on daemons on ADC... now the question is, will Apple allow me to submit a daemon to the Mac App Store?

    Edit: Looking through some of the MAS guidelines, it looks like I might have a bigger issue with the fact that applications aren't allowed to have root permission, which I imagine my app will require to lock and unlock files... still.. maybe Amazon will let me put the daemon on their store?
     
  4. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #4
    I doubt it, why wouldn't you want a menubar? Wouldn't you want your user to be able to enable/disable this function? How will the user be able to decide what file to "lock", what ever you mean by that, permissions, password protected encryption etc.
     
  5. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #5
    This is very much a one trick pony daemon. It detects the option key is pressed, locks a specific file (so that the system can't read from it... or write from it, I can see that causing issues, too...) and then it unlocks the file as soon as the option key is unlocked. It's a preference file the user might want the system to briefly not know the contents of.
     
  6. subsonix macrumors 68040

    Joined:
    Feb 2, 2008
    #6
    The option key is used a lot, to copy/paste and so on. It would now have the side effect of also "locking" (what ever that means) a system prefs file, you as a user would not have an obvious way of turning the function on/off or even see if it's active. Sounds like a design flaw if you ask me, why not use a menu bar where this can be set?
     
  7. admanimal macrumors 68040

    Joined:
    Apr 22, 2005
    #7
    It is doubtful at best that an app that does what you describe would even be accepted.
     
  8. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #8
    Yeah, so I'll just go ahead and say exactly what I want so I can at least make the program for myself.

    I want an easy way to launch an app without resume, so I could, for example, open a single Pages document that I double click without having every other Pages document that I had open last time opening as well, but without disabling resume for Pages entirely (because sometimes having every previous document open is exactly what I want, IE, after I have to restart my computer after a software update.)

    My understanding is that by locking Saved Application States (it's a file buried in your library,) you can prevent resume from automatically opening the files you had open last time.

    Thus, I'd like to make it so that by holding down a key while you launch an application, it locks the file and thereby stops resume, just for while you launch that app.

    I don't understand how to go about making an app like this though. I don't really even know where to begin. Any pointers?

    I know C and Obj-C and I've written Cocoa applications before, but I think I need to learn something lower level than that to accomplish this...

    I looked through Apple's docs on daemons and stuff, but their "Hello World" example just confused me... it looked like nothing more than a plist and I don't understand how one would make something that actually does what I want via a daemon...
     
  9. jared_kipe macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #9
    It should be pointed out that if you "lock" said file(s) when launching an app, and it launches with a new/empty window, at some point in the future it will probably write over the newly "unlocked" files with whatever you have open (thus losing the previous state)

    Hold shift while launching an application...
     
  10. wlh99 macrumors 6502

    Joined:
    Feb 7, 2008
    #10
    There is a systemwide preference for that. Instead of locking a file, why not change that system preference, and then change it back after the app launches?

    You could probably write a shell script to disable it, another shell script to enable it, and use automator from there.

    I would chose a key combination other than option by itself. Maybe option-r for restore.
     
  11. jared_kipe macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #11
    Would you think about holding the shift key, since holding shift already does the hypothetical app's desired function?
     
  12. ArtOfWarfare, Sep 18, 2011
    Last edited: Sep 18, 2011

    ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #12
    I wasn't aware that the shift key already did this, and I'm surprised that in all of my googling, I was never able to find that out.

    Unfortunately, holding shift only works when you're launching an application by clicking on the application itself. Launching an application by clicking on the document you want to open still has the resume behavior of having the document you want to open + every other document that was open last time all opening.

    This behavior is fine on my iMac which has plenty of screen space, memory, and processing power to open 5 documents at once, but on my MacBook Air, it's a very frustrating because it's wasting several minutes of my time opening documents I didn't want it to open.

    Thinking about the issue some more, I'd rather that the way Resume worked was that it only ran when you boot or restart your computer. Other than those, I'd rather if applications would launch exactly as they did under Snow Leopard and every version of Mac OS X prior to Lion.

    Is there some way for me to make it so Command-Q does what Option-Command-Q (Quit and Discard Windows) without making it so Resume doesn't run after a boot up or restart?
     

Share This Page