1

In AppleScript if you want to show the Script Menu in the menu bar you have to:

  1. Click Applications
  2. Scroll down and click Utilities
  3. Click Script Editor (this was called AppleScript Editor in older OS X versions)
  4. Click the “Script Editor” menu item, then click “Preferences...”
  5. On the Preferences dialog click “Show Script menu in menu bar”
  6. If it isn’t selected, you’ll want to enable the “Show Computer scripts” option

but is there a file in system that I can target to activate this in a script? Trying to build an installer that will turn this on when if not active but I'm having issues trying to find where in the system I can hit this. Dont mind a do shell but prefer not to use Automator.

3

10.13 (High Sierra) and before

If you do not want to have to go through Script Editor > Preferences > General to check the
[ ] Show Script menu in menu bar check box, then here is one way of enabling the Script Menu using AppleScript:

tell application "System Events"
    if not (script menu enabled) then
        tell current application
            do shell script "open '/System/Library/CoreServices/Menu Extras/Script Menu.menu'"
        end tell
    end if
end tell

You could just use:

do shell script "open '/System/Library/CoreServices/Menu Extras/Script Menu.menu'"

However, since System Events has a script menu enabled property, it makes sense to check whether or not it's enabled first. Either way though, opening the target file loads the Script Menu and checks the [√] Show Script menu in menu bar check box in: Script Editor > Preferences > General

Also, from Terminal, you could just run:

open '/System/Library/CoreServices/Menu Extras/Script Menu.menu'

Opening the target file in any manner shown accomplishes the goal.

By the way, when the Script Menu is enabled the target plist file is:

com.apple.systemuiserver.plist

The key is a Boolean and is NSStatusItem Visible com.apple.scriptmenu, and will also have an element in the menuExtras Array as a String holding the pathname of the item.

Note that the information above was gathered under macOS 10.13.5.


10.14 (Mojave) and up

The script menu has been upgraded into a full-fledged application, instead of a .menu file. It is now located at /System/Library/CoreServices/Script Menu.app.

To activate it on 10.14+, the terminal/shell command changes to:

open '/System/Library/CoreServices/Script Menu.app'
0

This preference is controlled by the plist at the following path: ~/Library/Preferences/com.apple.scriptmenu.plist.

Which contains the following (When off):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>ScriptMenuEnabled</key>
    <false/>
</dict>
</plist>

The false is changed to true when it is activated.

You change this preference with a defaults command in bash.

defaults write com.apple.scriptmenu.plist ScriptMenuEnabled true

or

defaults write com.apple.scriptmenu.plist ScriptMenuEnabled false

So in AppleScript:

do shell script "defaults write com.apple.scriptmenu.plist ScriptMenuEnabled true"

or

do shell script "defaults write com.apple.scriptmenu.plist ScriptMenuEnabled false"
  • I see the file but the running in the terminal and do shell doesn't work on the fly. Still searching for a solution without a reboot. – ʀ2ᴅ2 Jul 10 '18 at 18:49
  • 1
    In macOS 10.13.5 anyway, ScriptMenuEnabled is not a valid key in the com.apple.scriptmenu.plist file. From what I see there are only two valid keys for the com.apple.scriptmenu.plist file, PutAppScriptsFirst and ShowLibraryScripts. – user3439894 Jul 13 '18 at 11:59
  • @user3439894 I tested on Mojave but I suspect it would be same for all versions. – JBis Jul 13 '18 at 11:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .