BTT presets with applescript

If I am not wrong, there are only two actions for managing presets:

Do you know if there are more or different actions in Apple Script to manage BTT presets?

There is the export_preset and get_preset_details apple script function.

What are you looking for?

tell application "BetterTouchTool" to get_preset_details

(optionally provide the preset uuid after get_preset_details)

I was looking for an action in Apple Script like enable_preset or disable_preset (for enabling/disabling specific presets), instead of using the toggle action in BTT.

enable_preset could have an optional argument to set that preset as the master preset.

By the way, there is a problem with export_preset: info in this thread

So basically you want to enable or disable one specific preset without affecting the others?

Yes, that's it. I want to disable or enable one preset without affecting the others.

This would also allow to do an Apple Script to activate all the presets that are available in the presets list, using get_preset_details first and enable_preset later. IMO, this would be very useful to execute every time BTT is restarted.

Another cool feature would be to import presets, something like import_preset "~/BTTpresets/myPreset"

Here is a example apple script (JAX! so need to select JavaScript in Script Editor) you can use for now.
It first reads the current preset states and and only changes the one you specify above. Then it writes the preset states back by triggering the "Switch to Preset" action.

var BTT = Application('BetterTouchTool');

let presetNameToEnable = "some_preset"
let activateOption = 2; // 0 = disable, 1 = enable, 2 = enable and make master

let res = JSON.parse(BTT.get_preset_details())

let newPresetStates = {}
for (let preset of res) {
	if(preset.name == presetNameToEnable) {
	newPresetStates[preset.uuid] = preset.activated
	  newPresetStates[preset.uuid] = activateOption

	} else {
          // make sure to make the current master preset non-master when setting a new master preset
	  if(preset.activated == 2 && activateOption == 2) {
	  	  newPresetStates[preset.uuid] = 1

	  } else {
	  	  newPresetStates[preset.uuid] = preset.activated
		}

	}
}

BTT.trigger_action(JSON.stringify({
  BTTPredefinedActionType: 139,
  BTTPresetSwitchConfig: JSON.stringify(newPresetStates)
}))

Thanks!

It works perfectly.