I think it will be difficult for Andreas to provide variables for all the different NSNotifications. What you can do is to subscribe the event itself.
Create an AppleScript file with the following content:
script theScript
use framework "Foundation"
use scripting additions
property ca : current application
property NSString : a reference to ca's NSString
property workspaceClass : class "NSWorkspace"
on addObserver()
set ws to workspaceClass's sharedWorkspace()
set nc to ws's notificationCenter()
tell nc to addObserver:me selector:"deviceDidMount:" |name|:"NSWorkspaceDidMountNotification" object:(missing value)
end addObserver
on deviceDidMount:theNSNotification
set userInfo to theNSNotification's userInfo()
set theDevicePath to (userInfo's valueForKey:(NSString's stringWithString:"NSDevicePath")) as text
tell application "BetterTouchTool"
-- set BTT-Variable
set_string_variable "lastMountedDevicePath" to theDevicePath
-- trigger the named trigger
trigger_named "OnDeviceDidMount"
end tell
end deviceDidMount:
end script
theScript's addObserver()
Add the predefined trigger "After BTT was started" and add the action "Open Application / File / Apple Script". Select the script file.
Create a named trigger "OnDeviceDidMount" and add an action "Run Apple Script (enter directly as text)" with the following content for the test:
use scripting additions
tell application "BetterTouchTool"
-- get BTT-Variable
set theDevicePath to get_string_variable "lastMountedDevicePath"
-- make what ever you want…
display notification (theDevicePath) with title "DeviceDidMount:"
end tell
Restart BTT.
Note!:
The observer runs during the application is running which executed the script file (in this case BTT).
If the script file is called multiple times, multiple observer instances will be created.
Have fun!
Tested on Big Sur