Satimage Previous
Customizing the User Scripts menu
Home Documentation Smile The User Scripts menu Customizing the User Scripts menu  
Table of contents
The User Scripts folders Back to top
The User Scripts menu displays the contents of the User Scripts folders.

You can possibly use two User Scripts folders.
  • if you have no special reason for doing otherwise, use the User Scripts folder which is located in the user domain:
    /Users/<login>/Library/Application support/Smile/User Scripts/

    Smile automatically creates that folder.
  • to make items available to all accounts on the machine, use the local User Scripts folder:
    /Library/Application support/Smile/User Scripts/

    If the directory does not exist, create it, then quit and relaunch Smile.
  • the pre-installed items of the user scripts menu are stored in Smile's User Scripts folder, located in the same directory as the application file or in the application bundle itself:
    /Applications/Smile/User Scripts/, or
    /Applications/Smile/Smile.app/Contents/Resources/User Scripts/
The user scripts menu lists the contents of all the User Scripts folders, user domain last. If Smile does not find any User Scripts folder when it starts, it does not show the User Scripts menu.
Adding and removing menu items Back to top
  • Changes to the contents of the User Scripts folder are effective immediately on the User Scripts menu.
  • To add an item, copy the corresponding file to the User Scripts folder.
  • To remove an item, remove the corresponding file from the User Scripts folder.
  • To add or remove a sub-menu, add or remove the corresponding folder to or from the User Scripts folder.
Editing a user script Back to top
Selecting a script in the user scripts menu is how you run it. Selecting a script with the option key (⌥) pressed if how you open it. You are really opening a standard script file: it will show in a (colored) script window, where you can save your changes.
Displaying hierarchical menus Back to top
  • The User Scripts menu displays any folder located in the User Scripts folder as a sub-menu; like for the User Scripts folder itself, the sub-menu displays the list of the files located in that folder, in alphabetical order.
  • The same is true for folders nested at any level in such folders, making possible to design hierarchical menus of any depth.
  • The space character " " as the first character for the name of a folder located in the User Scripts folder has a special meaning, that the following section describes.
Grouping items Back to top
  • The folders in the User Scripts folder whose name begins with a space are treated specially: their contents is displayed directly in the User Scripts menu, not as a sub-menu. The name of the folder is not displayed.
  • A file or folder whose name starts with - (hyphen), or an alias to such a file, gets displayed in the User Scripts menu as a separating menu item: use this feature to separate blocks.
Using aliases Back to top
  • The User Scripts folder may contain aliases to files. The User Scripts menu displays the name of the original file, not the name of the alias file. Copying the alias of an application or the alias of a scripting addition into the User Scripts provides a convenient way of opening its dictionary.
Defining keyboard shortcuts Back to top
  • If the name of a user script ends with the slash character / followed by another character , for instance Send mail/@, the final character, @ in the example, can be used in combination with the ⌘ key as the keyboard shortcut for selecting the menu.
  • The shortcut is case-sensitive: if the final character is an uppercase character, for instance Just a Test /J, the shortcut combination is ⇧⌘ + 'key', for instance ⇧⌘J.
A slash in a file name is legal in the Macintosh; behind the scene it really translates into a colon : for the UNIX file system.
Defining keyboard shortcuts by script Back to top
By script you can customize the keyboard shortcuts to any extent, by editing the modifiers and shortcut properties of menu items.
  • The example below redefines the keyboard shortcuts for User Scripts ▸ More Smile commands ▸ Edit ▸ Copy/Paste Style ⇧⌘C/⇧⌘V as ⌥⌘C and ⌥⌘V like in TextEdit.
    set the_menu to menu item "Copy Style" of menu item "Edit" of menu item "More Smile commands" of menu "Scripts"
    set modifiers of the_menu to {option down}
    set the_menu to menu item "Paste Style" of menu item "Edit" of menu item "More Smile commands" of menu "Scripts"
    set modifiers of the_menu to {option down}
  • Typically, you will want such a script to run when Smile starts. To that effect install a compiled script in the directory below.
    /Users/<login▸/Library/Application support/Smile/More stuff/Initialization/
  • By script, you can edit the built-in menus as well as the User Scripts menu. The example below reassigns ⇧⌘N from File ▸ New script to File ▸ New Unicode text. Here we choose indexes rather than names to specify the menu items.
    set shortcut of menu item 2 of menu 2 to ""
    set shortcut of menu item 4 of menu 2 to "N"
    set modifiers of menu item 4 of menu 2 to {shift down}
  • When you set the modifiers property of a menu item Smile silently adds command down to the list: by default all keyboard shortcuts include the ⌘ key. To force a keyboard shortcut without the ⌘ key (which is not something strongly advised) include the string "no command" in the list for the modifiers property.

    You can use this feature, for instance, to install a set of personal text auto-completion commands on all the ctrl⇧-'letter' combinations. Be aware however that for reasons not related to Smile, installing huge sets of user menus slows down the computer in several circumstances (for example in the file browser dialogs).
Disabling, checking, and hiding menu items by script Back to top
Using the following properties you can add and remove a check mark ✓ before the menu item's name, you can disable (gray out) and re-enable, and hide and show, a menu item or a whole menu.
  • checked
  • enabled
  • visible
The following line hides the User Scripts menu. Replace false with true to show it back.
set visible of menu 7 to false
Version française
Copyright ©2008 Paris, Satimage