Programmatically changing system settings or linking to them? - cocoa

I want the user to be able to change the Notification Center system settings directly from my app without having to go to System Preferences app. I don't know if this can be done at all so I'm willing to settle for having them click a button that directly links to the Notifications pane of System Settings. That way they can be toggling some preferences from my native preferences window, and just click a button to quickly change whatever in the SS notifications and be done with it.

Preference panes are standalone executables. When you want to open a particular one, just launch it:
[[NSWorkspace sharedWorkspace]
openFile:#"/System/Library/PreferencePanes/Notifications.prefPane"];
Obviously you might want to check if the file is there, which might not be the case on older OS X versions.

Related

Applescripts cannot seem to target the Preferences Pane (Ventura)

I'm trying to use Automator to record an action on the system preferences, in the accessibility display pane. I want to change the value of the slider for the color filter intensity. (There are many similar questions asked here on SO, but they seem to be from 4-11 yr ago. I think the issue may be changes with Ventura, etc.)
I use automator to Watch Me Do and record the action. I reset the preferences manually. Clicking run does not cause the setting to change in preferences.
So I drag the actions from the Watch Me Do panel to the workflow timeline, which pop-out the action into an AppleScript. Running this is also not successful.
Can I manually set this preference in some way via the cli? When I search Apple developer docs, all I'm finding is Swift code to write an application. ((I realize that the app that will do this change, Automator, Terminal, or otherwise, will need to be granted accessibility permissions under privacy/security system preferences.))
Or how do I get/write an AppleScript to do this?
Also, I have checked the OSAX dictionary for System Preferences, and it does not have more specific controls registered besides at the basic window/pane/etc level

How do I only allow one instance of a window in Xcode (Swift)?

I'm designing a preferences window and I want it to act similarly to the ones on OS X's default programs - only one preferences window can be open at a time, and any attempts to open another one redirect the focus to the current prefs. window.
I realise I could make it modal but I want to know the best ways to handle a problem like this.

User settings' persistence in NPAPI?

I was wondering, if there's anything in NPAPI, which supports reading/writing user settings? Currently I use XPCOM, but I want to get rid of this code in order to support other browsers than Firefox.
I understand I can just read/write the file system (or registry on Windows) directly, but I want to explore other options - allowing the user edit these settings from the browser (e.g. about:config in FF) is, arguably, a better user experience than to direct him to edit some custom-made config files.
On the Mac plugins that need preferences sometimes ship a system preference pane with the plugin (and have a context menu item to open that pref pane), so that users have a UI for editing prefs. If there's not something similar for Windows and Linux you could always ship a small app that edits the prefs.
There is no such functionality in NPAPI.

How to assume/steal another process's windows as my own?

I'd like to show another app's windows under my app's taskbar button. It's a background app that reports another process's windows as my app's own. Is there any universal way to do this, e.g. each "new" window, alert glow, progressmeter, and other taskbar features, show under my own app's button?
For example, Winfox runs under its own process and steals Firefox's windows. It also adds features, but that's irrelevant -- I just want to support another app's existing taskbar features under my own app's button -- multiple windows, progressmeter, alert flashing, error flashing, mini-icons, etc. Is there a near-universal way to steal an app, or is it largely app-specific? Thanks!
You should be able to use SetParent() to take ownership of a window, but I'm not sure how much this will help you in your attempt to add taskbar features to the legacy app.

Xcode window positions when switching from dual to single monitor

When I'm working at home I plug my MacBook in to my 20" monitor as a second (right side) monitor. I do all my editing in Xcode on the larger monitor, and leave the menu bar, debugging and documentation on the laptop's monitor.
The problem is when I disconnect from the second monitor and want to work on code in "laptop" mode. Now, whenever I open a file for editing, it shows up almost entirely off the screen and I have to drag it over to edit it. I understand (sort of) why this is happening, since I last had it open in a different monitor. What I'd like to do is reset the window positions in Xcode so the edit windows show up completely on the laptop monitor. Any ideas on how to do this?
I'd even be willing to nuke entries out of the preferences (or set up an applescript to do it) but the xcode plist is inscrutable to me.
Right click the project in finder, select show package contents, and delete the two username.* files. Its not automated... but it works.
Additionally if your using some kind of version control system you probably want to add username.* to your ignore pattern.

Resources