How do I access System Settings in Sonoma?

I want to toggle the menubar off and on, but KM offers me only Preference Panes.

Are you trying to use KM to toggle the macOS switch called "automatically hide and show the menu bar"? Or are you trying to do something else like permanently disable the menu bar?

The toggle that macOS gives users to "automatically hide and show the menu bar" is available in the System Preferences App. It is indeed possible for a KM macro to open that app, and either use AppleScript or UI manipulation to change that toggle. It is also possible that this setting can be changed using the macOS defaults command, which doesn't require the UI. Which solution are you most interested in?

There is no "System Preferences App" in Sonoma.

What "macOS default command" are you referencing?

It takes me several clicks and scrolls to switch between "Always" and "Never" to hide or show the menu bar. If KM can do it for me, why do I need AppleScript to do it? I don't know a thing about AppleScript.

Is this on a per app basis, or do you want to change the setting while in the same app?

I meant System Settings, sorry. My mistake. That's the same app that you probably use currently to change this setting.

There is a macOS command called "defaults" (I didn't say "default" I said "defaults"). If needed we can probably use this command to assist you.

If KM can do it, it's probably by using one of the three methods I mentioned. I don't think it has any built-in command to do what you want. You may have to resort to one of my three methods. Which method are you most interested in?

EDIT: I see Nige is helping you too. His answers are generally twice as good as mine, so I'll let him take the lead.

I'm pretty dumb about KM. I use it only for a few keyboard swaps.

There's an existing command to hide/show the Dock: Command-Option-D. There's no similar keyboard command to hide/show the menu bar. I'm trying to use KM to create a shortcut.

This doesn't seem to be working.

Hey! System Settings has changed a lot, requiring some pretty esoteric stuff these days. So don't worry that you got a bit stuck.

You can open specific Settings panes will a special Apple URL scheme. You can do that with the Control Centre pane, but you can't easily scroll down to the menu toggle -- so we'll resort to some AppleScripting via System Events for the actual toggling.

Try this:

Menu Bar Switching.kmmacros (3.5 KB)

I don't seem to be invoking it correctly. It opens Control Center and stops.

Not sure if @Colinsky is seeing the same, but this is the error I'm getting:

image

G'ah! They obviously moved things again between Sonoma and Sequoia.

Try this script instead, which targets the last "group" of UI elements rather than the nth:

tell application "System Events"
	tell application process "System Settings"
		set theGroups to (get every group of scroll area 1 of group 1 of group 2 of splitter group 1 of group 1 of window 1)
		set theBtn to pop up button 1 of item -1 of theGroups
		tell theBtn
			if value of theBtn is "Never" then
				set theKey to "126"
			else
				set theKey to "125"
			end if
			click
			delay 0.1
			repeat 3 times
				key code theKey
				delay 0.1
			end repeat
			keystroke return
		end tell
	end tell
end tell

And I'll try and find a Sonoma machine to test on...

Getting this error now when trying to run the whole macro (previously I only tried the script action, sorry about that—force of habit):

image

(I'm on v15.1.1/Sequoia)

This still opens Control Center and stops. It doesn't reach the "Quit System Settings" action.

Thanks for your help. This is all way over my head

For now, just disable the "Execute an AppleScript" and "Quit System Settings" actions (it's an option under each action's "cogwheel", top-right corner) and just use the macro to open System Settings at the correct pane then make the change manually.

At least that'll save you a few clicks until we can get the rest sorted!

Thanks!

Alternatively, it could be fully automated using keystrokes to call the panel with spotlight. Not very pretty perhaps, but it's what I would do to save myself the seconds of annoyance having to open the app myself.

I think there are two issues:

  1. Timing -- the AppleScript was firing before the Settings pane was available. Added a "Pause Until..." the window exists
  2. Number of groups in the Settings pane -- this version targets the last group of the pane which, on all my machines, is the correct one

See how you get on:

Menu Bar Switching v2.kmmacros (4.7 KB)

Image

I've set it with the same hot key as you used in the screen shot above so you can use it as a standalone macro rather than calling it from another with the "Execute a macro" action.

Here is another option that I use - toggles hide/unhide

MenuBar Hide:unhide.kmmacros (18.5 KB)