Ah! Ok I rewrote Gustavo’s script to rebuild the menu each time it's run. So I can just rerun the script when I want it to update.
# menuTitle: _ Add / Update Custom Scripts Menu
from AppKit import NSApp, NSMenu, NSMenuItem
from lib.UI.fileBrowser import RFPathItem
def addMenu(name, path):
'''Creates a new menu item in RoboFont’s main application menu.'''
# create a new menu
menu = NSMenu.alloc().initWithTitle_(name)
# create a path item that will build the menu and connect all the callbacks
pathItem = RFPathItem(path, ['.py'], isRoot=True)
pathItem.getMenu(title=name, parentMenu=menu)
# get the main menu
menubar = NSApp().mainMenu()
# search if the menu item already exists
newItem = menubar.itemWithTitle_(name)
if newItem:
menubar.removeItem_(newItem)
newItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_(name, '', '')
menubar.insertItem_atIndex_(newItem, menubar.numberOfItems()-3)
# set the menu as submenu
newItem.setSubmenu_(menu)
addMenu('menu name', '/path/to/folder/')
Key lines:
if newItem:
menubar.removeItem_(newItem)