Change settings (preferences) from within script

Is there a way to change settings (preferences) from within a script?
If not, I'd like to request something that enables this.
A settings interface might look something like (pseudo code):

PrefCategory.PrefPage.PrefObject = {
	public string or type Type {get;}
	public string Name {get;}
	public string Description {get;}
	public object Default {get;}
	private object _value;
	public object Value {get; set {
		if(value==valid)
			this._value = value;
		else
			throw("Invalid");
	}}
	public void Reset(){
		this._value = this.Default;
	}
	...
}

and maybe, on the global settings object, methods like "apply" and "cancel" to handle script changed settings in a separate buffer.
So that we can interact with the settings (iterate through them, inspect them, change them)
Might need to supply type interfaces for things not readily available in DOpus's JScript

That would be neato :blush:

Script can run commands, and commands can change most Preferences settings that you'd want to change back & forth.

Do you mean like with SET and GO?
Or is there a specific command for this?

Various commands, depending on the setting.

It'd be easier to help if you have something specific in mind that you need to do.

In particular, I was wondering if I could set the File Display background color.
But that was just a reason to ask for a unified way to set preferences from script

That's not something that can be changed on the fly, or for individual file displays.

You can change the accent color on the folder tab to highlight things, but the background color/image is a global thing without a command to change it. (Beyond the way you can define different colors for different modes, like source/dest/off and whether filtering is on or off.)

That what it looked like.
Will you guys think about adding a general, unified interface for interacting with settings?
That should be a one-time thing and could tie in with an existing serialization/deserialization system for "non-straight-forward" data types.

I think you're focusing on the wrong thing here. There is already a good way to change and test settings in scripts, and the exactly method for doing that isn't what's stopping you from changing this particular setting. It's the fact it isn't a setting that can be changed on the fly at all.

But even if it could be changed on the fly, I'm not sure if it would do what you want (as I'm not sure what you're actually trying to do). If your aim is to only change the background color of a particular file display, not all file displays at once, then there is no existing Prefs setting which can do that, and making every Prefs setting editable via scripts wouldn't help.

Rather than suggest changing the details of how scripts can change settings, it'd be better if we talked about what you actually need to do and why. Depending on what it is and how complex it is to implement, and the benefits it might give you and other users, we may be able to add functionality to do it, and some method of doing so via scripting as well. The exact method doesn't really matter and shouldn't be what we're focusing on here, especially when it's not yet clear what you want to do.

Huh? Now I'm confused.
I'm simply talking about changing the background color for all file displays, as exposed in the settings dialog under Display > Colors and Fonts > File and Folder Colors > File display background
This is A) an existing setting, B) can be changed on the fly, and C), in so far as I understand it, is an example of a settings/preferences property that can not be changed via script yet.
The existence of properties which have no scripting interface suggests to me the usefulness a neat interface like that would present.

I started out having to inspect a folder with hundreds of black .svg files with my originally black file display background. Sure, I can change that for any single occasion, but that got me thinking along the lines of "I'd like to see if I could write a command that directly displays a color picker and sets the background accordingly" and "wouldn't it be neat to set some colors based on any number of things automatically". (If you need to differentiate between listers and/or folders/tabs, you can easily keep track of and manage defaults and preferences along with active tab change, lister change, etc yourself)

As I understand it, the thing standing in my way is the lack of a script interface. Or is there a way of setting this using commands after all?

The thing standing in your way is a lack of a command to change that one setting. We can add that to our to-do list. A whole new scripting API for Preferences settings is not needed just to change one additional setting. :slight_smile:

(It'll probably be a while before this is implemented because we're planning to overhaul the way the color settings work in Preferences to make it easier for us to add more colors, and this ties into that. We'll make it so every color has a name and can then be changed via a command. Still won't require a new scripting API; just some new arguments to one of the existing commands.)

That's great news :slight_smile:
As you could probably tell, I'm in no particular hurry (or indeed actual need) to work with this.
My hobby programmer heart just saw how there has to be a specific command added manually for every setting, which a scripting language will then have to ask DOpus to run as a command which may be defined and implemented any number of ways, and I couldn't help but dream of an elegant, unified, slightly more direct and lower level way to handle all settings without the need of much further interference in the future, specialized documentation, reacting to us whiny users requesting commands to change yet another setting, etc.
I still think it would be the "right thing to do", but this isn't my baby and you know best.

Thank you for indulging me, and have a great day! :blush: