How to Automate Menu Bar Icons with AppleScript

For power users, clicking is slow. Learn how to control SaneBar programmatically using AppleScript, Raycast, Alfred, or Shortcuts.

SaneBar is built with automation in mind. Unlike other menu bar managers that rely on private APIs or accessibility hacks, SaneBar exposes a clean AppleScript dictionary.

Basic Commands

You can run these commands from Terminal (using osascript) or the Script Editor app.

-- Toggle visibility of hidden items
tell application "SaneBar" to toggle

-- Explicitly show hidden items
tell application "SaneBar" to show hidden

-- Explicitly hide items
tell application "SaneBar" to hide items

Use with Raycast or Alfred

You can create a script command in Raycast or a Workflow in Alfred to toggle your menu bar without lifting your hands from the keyboard.

Raycast Setup

  1. Create a new Script Command.
  2. Select "AppleScript" as the language.
  3. Paste tell application "SaneBar" to toggle.
  4. Assign an alias (e.g., "mb").

Advanced: Context-Aware Logic

Since you can query the state, you can build complex logic. For example, "If I launch Zoom, ensure menu bar icons are hidden to avoid distractions."

tell application "System Events"
if (name of first application process whose frontmost is true) is "zoom.us" then
tell application "SaneBar" to hide items
end if
end tell

Get the Hackable Menu Bar Manager

SaneBar gives you full control. Script it, style it, lock it.

Buy Now - $6.99

← Back to Guides