Where are scripts stored?

I recently extened a script that I trigger with a keyboard shortcut but today I find that it somehow went back to the earlier version (i.e. without the new code). Since I am syncing my settings via Dropbox, I suspected a sync issue and wanted to see if I can recover earlier versions of the file.

The problem is: I can't seem to figure out where that script is saved. I looked through all the folders in the Dropbox folder but found most of them to be unmodified for at least a year. And among the ones with a more recent Last Modified date, I couldn't identify one with a script.

Where am I going wrong? Did I not look close enough? Or am I looking in the wrong place?

In case it matters: the script is an AppleScript in an action that is part of a Named Trigger.

all of BTT's database is stored in ~/Library/Application Support/BetterTouchTool, however you won't be able to extract single elements like scripts. It's all stored in a database. You also won't be able to recover them from Dropbox because BTT only stores the diffs / update objects in Dropbox (in ~/Library/Application Support/com.hegenberg.BetterTouchTool/com.mentalfaculty.ensembles.eventdata/MainStore.v2)

The Dropbox sync is indeed very experimental and it will be replaced later this year with a much better solution. I would not recommend to use it at the moment.

BTT however does create auto backups from time to time. Maybe you can restore one via Help => Restore Settings from Backup (disable sync before doing so)

1 Like

Unfortunately, the last backup is from July, way before I amended the script.

I do, however, have backups which should include most of the Library folder. Which files would I restore?

I edited the script on 11 Aug, so the last modified dates of some of the files look promising. Can I just restore the three files from version 4.643?

@Andreas_Hegenberg :

I have a related question:

I'm finding that my scripts (mostly javascript) are getting complicated enough that I often want to either look at the changes since a previous version, or roll back just that script to a previous version.

These are things that a version control system does well. Is there any way to store the scripts for Javascript and Apple script actions/triggers/widgets in a version control system rather than in whatever BTT usually uses, and/or to import an entire set of scripts to triggers from known locations?

(I guess that I could try and use BTT do to that last thing, which is appealing because it is self-referential, but it seems like it would be fragile and likely to break on changes to the BTT UI...)

If this is not currently possible, would you be open to adding a way to do this, maybe just as a text box for script actions that specifies a location in the file system where the script is read from at BTT start? (and maybe re-read and written to when that script is opened and saved in the BTT UI).

This could provide some added advantages in that it would allow scripts to be opened in other editors (e.g. VS Code) and might make it easier for a set of scripts implementing a preset to be be shared for collaboration as a GitHub or other repo.

Thanks for considering!

yes having an option to store scripts at a specific location is definitely needed and will be added very soon!

2 Likes

yes, just delete any files with higher versions, then BTT will fall back to the older ones

1 Like

BTT 4.683 now adds options to store Apple & Java Scripts externally. You can now choose between

  • inline (stored in BTT's database)
  • preset file (stored in the active preset's folder in ~/Library/Application Support/BetterTouchTool/PresetBundles
  • external file with custom location

1 Like

@Andreas_Hegenberg

I just started using the new option to store scripts externally. It's great, I have my scripts in git and can edit in an IDE, and BTT does a good job of noticing changes and updating when necessary.

Thank you very much for this change! :slight_smile: