Re: Prevent screen saver from starting, but don't prevent computer sleep
You can make your app trigger a command-line program and pass params using NSTask. It’s not difficult to use. But in this case you might want to negotiate this with the user - apps that just go ahead and change MY system preferences are being user-hostile to say the least. —Graham > On 28 Jun 2020, at 2:46 am, Gabriel Zachmann via Cocoa-dev > wrote: > > Basically, what I'd like to do in my app is what I can do using this on the > command line: > > defaults -currentHost write com.apple.screensaver idleTime ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Launching in fullscreen gives "Funk" sound sometimes
On Jun 24, 2020, at 5:23 AM, Gabriel Zachmann via Cocoa-dev wrote: > I tried to add this in -viewDidLoad in MasterWindowController: > >[[[self view] window] makeKeyAndOrderFront: NULL]; Some questions that may or may not help: - Are you sure the above line of code is being called? (I would check with a NSLog rather than a breakpoint. Using a breakpoint can cause the active application to change, which you may not want. You want to see what's happening when your app launches without *affecting* what's happening.) - Did you mean -windowDidLoad rather than -viewDidLoad? - What is the application *supposed* to do when you type keystrokes? - I saw the thread earlier where you moved some logic into applicationWillFinishLaunching:. What if you add back applicationDidFinishLaunching: and move just the full-screen toggling code there (and keep the rest in applicationWillFinishLaunching:)? - Are you sure your application is the active application when you're typing those keystrokes? You can check this by adding applicationDidBecomeActive: and applicationDidResignActive: methods to the application delegate, and having them call NSLog. I'm not sure offhand if makeKeyAndOrderFront: makes the application active. - Does your window have an initialFirstResponder? Not sure this would make a difference in your case, but might in some circumstances. The initialFirstResponder can be set in Interface Builder. --Andy ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Prevent screen saver from starting, but don't prevent computer sleep
G, > On Jun 27, 2020, at 12:47, Gabriel Zachmann via Cocoa-dev > wrote: > > Does anyone know how to programmatically disable macOS from launching the > screen saver on macOS? > I would like to do that in one of my apps. Not sure in general, but in a managed host situation this type of system modification could be disallowed by policy. Even admin users of a managed system can be barred from changing settings like these as they can affect security, eg when passwords must be prompted. You wouldn’t want any person to be able to walk by and quit your app and have access to the user’s files. Anyway, probably not an issue for the majority of your users, but something to thing about… Sandor > > Note that I do NOT want to disable screen sleep, nor system sleep. > I just want to set the idle time to "Never" , which you would do manually by > going > to System Preferences / Desktop & Screensaver / Start after ... > > Basically, what I'd like to do in my app is what I can do using this on the > command line: > > defaults -currentHost write com.apple.screensaver idleTime > > but I want to do it in my app. > And, of course, I'd like to restore the former setting when my app quits. > > My app does not use a lot of compute resources, and it is perfectly fine if > and when the Mac goes to sleep after the idle time set in System Preferences > / Energy Saver / Turn display off after ... > > I googled a lot , but I only found hints at using the function > IOPMAssertionCreateWithName(); however, this does not seem to provide an > option for the screen saver. > It seems to me it's just useful to turn off computer sleep. > > Also, I found the tool caffeinate, but, again, this seems to me the wrong > utility, because it is all about computer sleep, too. > > Any ideas or suggestions would be highly appreciated. > Best regards, Gabriel > > > > > ___ > > Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) > > Please do not post admin requests or moderator comments to the list. > Contact the moderators at cocoa-dev-admins(at)lists.apple.com > > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com > > This email sent to admin.szatmari@gmail.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Prevent screen saver from starting, but don't prevent computer sleep
Does anyone know how to programmatically disable macOS from launching the screen saver on macOS? I would like to do that in one of my apps. Note that I do NOT want to disable screen sleep, nor system sleep. I just want to set the idle time to "Never" , which you would do manually by going to System Preferences / Desktop & Screensaver / Start after ... Basically, what I'd like to do in my app is what I can do using this on the command line: defaults -currentHost write com.apple.screensaver idleTime but I want to do it in my app. And, of course, I'd like to restore the former setting when my app quits. My app does not use a lot of compute resources, and it is perfectly fine if and when the Mac goes to sleep after the idle time set in System Preferences / Energy Saver / Turn display off after ... I googled a lot , but I only found hints at using the function IOPMAssertionCreateWithName(); however, this does not seem to provide an option for the screen saver. It seems to me it's just useful to turn off computer sleep. Also, I found the tool caffeinate, but, again, this seems to me the wrong utility, because it is all about computer sleep, too. Any ideas or suggestions would be highly appreciated. Best regards, Gabriel smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Launching in fullscreen gives "Funk" sound sometimes
Thanks a lot for the hint. I have now managed to find the time to try it out, alas, it's not the other app either that creates the "Funk" sound. Could it be that no app at all has the keyboard focus? And how can I make sure that my app really has the focus? Best regards, Gabriel > > It’s possible that the “funk” sound is coming from the other app if it still > has keyboard focus. Try attaching to that instead and seeing if it hits > NSBeep. > > Saagar Jha > >> On Jun 25, 2020, at 02:09, Gabriel Zachmann via Cocoa-dev >> wrote: >> >> >>> >>> Set a symbolic breakpoint on NSBeep and see whether it?s your code that?s >>> calling it. >>> >>> >> >> Thanks a lot for the hint! >> >> I think I managed to do that (it's a bit tricky, since my app gets launched >> in fullscreen mode by some other app). >> Alas, the debugger did not break at any time when I heard the "Funk" sound. >> So, I guess, we can conclude that my app does not call NSBeep(). >> >> Maybe, the keyboard focus is still on some other app? >> and that's why I 'm hearing the "funk" sound, because I am typing a key that >> is meaningful for my app, but not for the other app. >> >> Or could it be that my app still has some other (hidden) windows open, >> behind the fullscreen window, which somehow produce the "funk" sound? smime.p7s Description: S/MIME cryptographic signature ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com