Preference switch between startup files


Inherits from: Object 


SuperCollider has no system application preferences; instead it allows to specify startup files which contain  code that is evaluated when the application starts, or after the class library is recompiled. Preference helps to keep several such setups (preferences) and switch between them, e.g. for different situations like performance, developing, teaching.


The setups are stored next to the startup file in a folder called "startupfiles". This folder can be used for multiple custom setups. They can be switched using the Library Menu (Library>startup, Mac OS only), or by command line (see below). Filenames for startup files in that folder should contain the word "startup" - all other files are ignored and can be used to share functionality between different settings.


Note: in order to use preference switching, move your startup file to the startupfiles folder first.



Class Variables

*current Name of the currently active Preference

Preference.current;


*openFileAtStartup

*openFileAtStartup_ If true, open all startup file folders on startup (default: true)

repositoryDirPath

repositoryDirPath_ The directory in which the repository is added. This is automatically found, unless specified in the current startup file.

Preference.repositoryDirPath; // the path

startupFilePath

startupFilePath_ The path of the startup file. This is automatically found, 

unless specified in the current startup file.


Preference.startupFilePath; // the path


Class Methods


*initClass

Compiling the library, the repository of startup files is built and can be accessed via the library.

This method is called after the startup has run, so one startup may configure the behavior of the Preference class (this may concern paths and openFileAtStartup).

*set(which)

Set the startup file to a given file name (symbol). This creates a symlink that links "startup.rtf" to the file in the startupfiles folder named "which".


Preference.set(\oldschool_startup);


*setToDefault

Set the startup file to a default startup (any file just named startup.rtf or startup.scd etc.). 

If none exists, it uses no startup file (see .reset).

Preference.setToDefault;


*fileNames

A dictionary of names and file paths.

Preference.fileNames.keys; // the names

Preference.fileNames.values.printcsAll; // the paths


*openStartupFile

Open the current startup file

Preference.openStartupFile;

*openRepository

Open the repository directory

Preference.openRepository;

*reset

Use no startup file.

Preference.reset;

Preference.current; // returns 'none'