Seach everything

Hey Andreas, is there a way to search across all triggers, across all apps (on the left side)? This could be further enhanced with search across all apps for a particular trigger group (e.g. keyboard, touchpad etc.).

Thank you in advance.

I usually run this command to search across all triggers, apps, etc.

osascript -e 'tell application "BetterTouchTool" to get_triggers' | jq

Unfortunately, I almost always get this error:

╭─   ~ ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────  base  22.14.0  00:45:08
╰─❯ osascript -e 'tell application "BetterTouchTool" to get_triggers' | jq
38:50: execution error: BetterTouchTool got an error: AppleEvent handler failed. (-10000)

This usually happens after I download a preset. I then need to carefully start removing triggers one by one until the osascript -e 'tell application "BetterTouchTool" to get_triggers' | jq works again. That being said, when the command works, it's great!

Also, I added these two functions to my ~/.zshrc file to easily search Triggers in BTT:

# Function to run get_triggers in BTT with optional parameters using --argument_name syntax
get_triggers() {
  local trigger_type=""
  local trigger_id=""
  local trigger_parent_uuid=""
  local trigger_uuid=""
  local trigger_app_bundle_identifier=""

  while [[ $# -gt 0 ]]; do
    case "$1" in
      --trigger_type)
        trigger_type="$2"
        shift 2
        ;;
      --trigger_id)
        trigger_id="$2"
        shift 2
        ;;
      --trigger_parent_uuid)
        trigger_parent_uuid="$2"
        shift 2
        ;;
      --trigger_uuid)
        trigger_uuid="$2"
        shift 2
        ;;
      --trigger_app_bundle_identifier)
        trigger_app_bundle_identifier="$2"
        shift 2
        ;;
      *)
        echo "Unknown argument: $1"
        return 1
        ;;
    esac
  done

  osascript -l JavaScript <<EOF | jq
  const BetterTouchTool = Application('BetterTouchTool');
  const triggerOptions = {};
  if ("$trigger_type") triggerOptions.trigger_type = "$trigger_type";
  if ("$trigger_id") triggerOptions.trigger_id = "$trigger_id";
  if ("$trigger_parent_uuid") triggerOptions.trigger_parent_uuid = "$trigger_parent_uuid";
  if ("$trigger_uuid") triggerOptions.trigger_uuid = "$trigger_uuid";
  if ("$trigger_app_bundle_identifier") triggerOptions.trigger_app_bundle_identifier = "$trigger_app_bundle_identifier";
  const triggers = BetterTouchTool.get_triggers(triggerOptions);
  triggers;
EOF
}

# Function to run get_trigger
get_trigger() {
  local uuid="$1"
  osascript -l JavaScript -e "Application(\"BetterTouchTool\").get_trigger(\"$uuid\");" | jq
}

I think there is a limitation in how much data apple script can return and triggers with big images or similar cause this to be exceeded. (I'm not 100% sure whether this is the case but it has been my observation in a few limited tests)

Would be interesting to know whether the built in webserver (when activated) has the same issue.

http://127.0.0.1:50863/get_triggers/?
(requires a ? at the end at the moment, even if no parameters are used)

1 Like

Once I active the webserver and try to access it BTT Version: 5.450 (2025060201) crashes. Am I missing something?

@fortred2, thank you for this, I was expecting something similar to be possible using scripting, but my ask if this is possible in the UI, and if it not - can it be a implemented?

Maybe it is encountering the same issue @fortred2 mentioned, could you send the crash log to me?

Global search in BTT's UI is definitely something I would like to add, but it is complicated. Has been on my TODO list for a long time.

1 Like

Sent the crash report via the email. Running the below command, does not cause crash, only when access the webserver (no matter if via browser or curl)

osascript -e 'tell application "BetterTouchTool" to get_triggers' | jq