Modify EditorSettings from Command Line Script

Godot Version



Hi, I’m writing a helper shell script to install the FBX importer and set the editor’s path to the importer. To do this, I am trying to call a gdscript from the command line that can modify the EditorSettings.

However, accessing EditorSettings from a command line gdscript seems more difficult than anticipated. EditorInterface.get_editor_settings() doesn’t work in this context. From what I can find, it only works from EditorPlugin scripts. But if I go that route, the script is not callable from the command line (must extend from SceneTree or MainLoop).

So, is it just impossible to access the EditorSettings from a command line script, or is there some other clever method I can use to get the EditorSettings instance and modify it from a command line script?

(For context, I am trying this script approach because the alternative is to modify the editor-settings-4 file using shell commands like awk/sed…but it’d be easier to do this through the Godot interface for modifying EditorSettings I think!)

I don’t know how you’d do some of the things you’re describing, but if it helps the editor settings live in a .tres file in the user’s AppData (or Library on Mac).

Mine lives at <User>\AppData\Roaming\Godot\editor_settings-3.tres"

And it’s pretty human readable

[gd_resource type="EditorSettings" format=2]

text_editor/highlighting/symbol_color = Color( 0.67, 0.785, 1, 1 )
text_editor/highlighting/keyword_color = Color( 1, 0.44, 0.52, 1 )
text_editor/highlighting/control_flow_keyword_color = Color( 1, 0.55, 0.8, 1 )
text_editor/highlighting/base_type_color = Color( 0.26, 1, 0.76, 1 )
text_editor/highlighting/engine_type_color = Color( 0.556, 1, 0.856, 1 )
text_editor/highlighting/user_type_color = Color( 0.778, 1, 0.928, 1 )
text_editor/highlighting/comment_color = Color( 0.8, 0.8075, 0.8275, 0.5 )
text_editor/highlighting/string_color = Color( 1, 0.925, 0.63, 1 )

If you are launching the godot executable from the command line you can use a small project that only has a scene with a script in @tool mode that access the EditorInterface singleton.

For example, launch the Godot editor with --editor --path and --headless where --path points to the directory where the small project is.

The small project has 2 files:



And main.tscn

[gd_scene load_steps=2 format=3 uid="uid://db1p6yliwwv5g"]

[sub_resource type="GDScript" id="GDScript_hsvby"]
script/source = "@tool
extends Node

func _enter_tree() -> void:
	var settings = EditorInterface.get_editor_settings()
	# Do stuff

[node name="Node" type="Node"]
script = SubResource("GDScript_hsvby")

Thanks for the responses!

I think the small project approach could do the trick - it’s a bit of extra setup, but good to know there is a way to do it!

I ultimately went with a command line approach with the tool “sed”…but it only works because the structure of the preferences file is a certain way. Definitely not the most flexible solution:

sed -i "" '/filesystem\/import\/fbx\/fbx2gltf_path/d' "${SETTINGS_PATH}"
echo "filesystem/import/fbx/fbx2gltf_path = \"${FBX_INSTALL_PATH}\"" >> ${SETTINGS_PATH}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.