imagestartupsmalltalkpreferencespharo

How can I set custom StartupPreferences for a particular Pharo image?


I want a particular image to be run with specific settings at start tiime as noted here

StartupPreferencesLoader default executeAtomicItems: { (StartupAction
             name: 'Start Literate Server'
             code: [
                 | class |
                 class := Smalltalk at: #LiterateServer ifAbsent: [
                              Metacello new
                                  baseline: 'LiterateSmalltalk';
                                  repository: 'github://jingtaozf/literate-smalltalk';
                                  onConflict: [ :ex | ex allow ];
                                  load.
                              Smalltalk at: #LiterateServer ].
                 class ifNotNil: [ LiterateServer start ] ]
             runOnce: false) }

Is there some way to accomplish this?


Solution

  • I found on old tutorial that explains the steps Tips and Tricks Booklet from 2017

    It involves creating some StartupActions which are executed when the image is loaded.

    My need is for start up settings that are specific for particular image and hence are saved in a file in the image's directory rather than the shared preferences directory for Pharo in general or the VM versions shared directory.

    | items |
    items := OrderedCollection new.
    items add: (StartupAction
                  name: 'Start Literate Server'
                  code: [
                     | class |
                     class := Smalltalk at: #LiterateServer ifAbsent: [
                                  Metacello new
                                      baseline: 'LiterateSmalltalk';
                                      repository: 'github://jingtaozf/literate-smalltalk';
                                      onConflict: [ :ex | ex allow ];
                                      load.
                                  Smalltalk at: #LiterateServer ].
                     class ifNotNil: [ LiterateServer start ] ]
                  runOnce: false).
    
    StartupPreferencesLoader default
      addAtStartupInImageDirectory: items.
    

    This resulted in a file startup.st having the following contents.

    StartupPreferencesLoader default executeAtomicItems: {
        StartupAction name: 'Start Literate Server' code: [ 
                     | class |
                     class := Smalltalk at: #LiterateServer ifAbsent: [ 
                                  Metacello new
                                      baseline: 'LiterateSmalltalk';
                                      repository: 'github://jingtaozf/literate-smalltalk';
                                      onConflict: [ :ex | ex allow ];
                                      load.
                                  Smalltalk at: #LiterateServer ].
                     class ifNotNil: [ LiterateServer start ] ].
    }.