Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Have you considered trying to drive the pref pane itself using AppleEvents/OSAScript? While the Network prefs pane seems to be the only one with fully built-out scriptability, you can drive any UI with System Events. It was easy enough to prototype in AppleScript. Here's what I came up with:</p> <pre><code>tell application "System Preferences" reveal pane "Date &amp; Time" reveal anchor "ClockPref" of pane "Date &amp; Time" tell application "System Events" tell tab group 1 of window 1 of process "System Preferences" repeat with cbIndex from 0 to count of checkboxes tell checkbox cbIndex if title contains "menu bar" then click exit repeat end if end tell end repeat end tell end tell quit end tell </code></pre> <p>You can either use it as is by using an NSAppleScript object, or if you're feeling masochistic, you can dive in to the minutia of figuring out just the right AppleEvents to send. (I recommend the former approach for sanity, but the latter will execute faster at runtime.)</p> <p>Pros: Easy.</p> <p>Cons: Launches System Preferences (which can be seen to be bouncing in the Dock), Requires "Enable Access for assistive devices" to be enabled (like many other things)</p> <p>Hard to say if this is <strong>visually</strong> better or worse that killing SystemUIServer, but it's almost <strong>certainly</strong> kinder to any other components that might be interacting with SystemUIServer.</p> <p>As far as getting rid of the dock bounce, this <a href="https://stackoverflow.com/questions/4284256/run-another-application-using-applescript-without-showing-it-on-the-dock">question over here</a> mentions how to get things to start up without a dock icon. To this I can add that in the past, I've wrangled with this problem, and the solution I came up with was, at a high level, this:</p> <ul> <li>Get a unique/safe temp directory </li> <li>Make a hard-links only mirror of the entire bundle of the app in question (<code>pax -rwl</code> will help with this)</li> <li>Replace the hard-linked Info.plist with a real copy of Info.plist</li> <li>Edit the copy per the directions in the other question. (Note: There are other options than setting <code>NSUIElement = true</code> here, but I leave those as an exercise for the reader and google.) </li> <li>Use the application from the temp directory</li> <li>Delete the temp directory.</li> </ul> <p>This approach has proven quite robust for me when trying to drive 3rd party applications. I'm guessing that you might, in the future, run into problems with system applications which are signed/sandboxed. (i.e. changing their Info.plist changes the signature, they may refuse to run.) Also, naturally, any sandboxed app will require a specific entitlement or exception to send AppleEvents at all, but I would guess this is also true of killing system processes (if that's even possible to do from a sandboxed app at all.)</p> <p>Lastly, you should <a href="http://bugreport.apple.com" rel="nofollow noreferrer">file a bug report with Apple</a> requesting first-class API or scriptability for this if you feel it's important.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload