{ "BTTPresetCreatorNotes" : "", "BTTPresetInfoURL" : "https://sw27.net/btt/", "BTTPresetName" : "Hold Command+Q 2.0", "BTTPresetColor" : "255, 70, 29, 255", "BTTPresetUUID" : "57721676-8453-49FD-B4B7-2C957FFAE8E8", "BTTPresetContent" : [ { "BTTAppBundleIdentifier" : "BT.G", "BTTAppName" : "Global", "BTTAppAutoInvertIcon" : 1, "BTTTriggers" : [ { "BTTGestureNotes" : "Hold Command+Q 2.0", "BTTTriggerType" : 0, "BTTTriggerClass" : "BTTTriggerTypeKeyboardShortcut", "BTTPredefinedActionType" : 281, "BTTPredefinedActionName" : "Run Real JavaScript", "BTTRealJavaScriptString" : "'use strict'; const cTime = Date.now(); (async () => {\n\n \/\/ **************************************************\n \/\/ setup\n\n \/\/ The length to press command + q. (milliseconds)\n \/\/ default: 700\n const holdTime = 700;\n\n \/\/ Repeat Rate (milliseconds)\n \/\/ default: 50\n const rRate = 50;\n\n \/\/ Display HUD\n \/\/ default: false\n const hud = false;\n\n \/\/ A list of applications to ignore. (BundleIdentifier)\n \/\/ default: 'com.apple.finder',\n \/\/ 'com.hegenberg.BetterTouchTool'\n const ignApps = [\n 'com.apple.finder',\n 'com.hegenberg.BetterTouchTool'\n ];\n\n \/\/ **************************************************\n\n const gs = 'get_string_variable', ss = 'set_string_variable', v = 'variable_name', sw = 'sw27_hcq', bttUuid = '66657AB0-19DA-49E4-8D57-60077A1B6734';\n const bttVal = await callBTT(gs, {[v]: sw});\n\n if (bttVal) {\n const [lTime, cnt] = bttVal.split(',').map(n => +n);\n\n if (cTime - lTime > rRate * 2) {\n await startCount();\n } else if (cnt < holdTime \/ rRate) {\n await callBTT(ss, {[v]: sw, to: cTime + ',' + (cnt + 1)});\n } else {\n await callBTT('update_trigger', {uuid: bttUuid, json: JSON.stringify({'BTTRepeatRate': 0})});\n\n await callBTT(ss, {[v]: sw, to: cTime + ',0'});\n const appId = await callBTT(gs, {[v]: 'BTTActiveAppBundleIdentifier'});\n\n if (ignApps.find(ignApp => ignApp == appId) === undefined) {\n await runAppleScript(`tell app id \"${appId}\" to quit`);\n }\n\n await callBTT('update_trigger', {uuid: bttUuid, json: JSON.stringify({'BTTRepeatRate': rRate \/ 1000})});\n }\n } else {\n await startCount();\n }\n\n returnToBTT(0);\n\n \/\/ Restart counter and display HUD\n async function startCount() {\n const json = JSON.parse(await callBTT('get_trigger', {uuid: bttUuid}));\n\n if (rRate \/ 1000 == json.BTTRepeatRate) {\n await callBTT(ss, {[v]: sw, to: cTime + ',0'});\n } else {\n await callBTT('update_trigger', {uuid: bttUuid, json: JSON.stringify({'BTTRepeatRate': 0})});\n\n await runAppleScript(`\n tell app \"BetterTouchTool\"\n activate\n set dTtl to \"Hold Command+Q\"\n set dMsg to \"Change Repeat Rate: ${rRate}\\nPlease retry Hold Command + Q\"\n display dialog dMsg with title dTtl with icon note buttons {\"OK\"} default button 1\n end tell\n `);\n\n await callBTT('update_trigger', {uuid: bttUuid, json: JSON.stringify({'BTTRepeatRate': rRate \/ 1000})});\n\n return false;\n }\n\n await callBTT(ss, {[v]: sw, to: cTime + ',0'});\n\n if (hud) {\n const appId = await callBTT(gs, {[v]: 'BTTActiveAppBundleIdentifier'});\n\n ignApps.find(ignApp => ignApp == appId) === undefined\n ? callBTT('trigger_action', {json: JSON.stringify({\n 'BTTPredefinedActionType': 254, 'BTTPredefinedActionName': 'Show HUD Overlay', 'BTTHUDActionConfiguration': '{\"BTTActionHUDTitle\":\"⌘Q\",\"BTTActionHUDDuration\":0.9,\"BTTActionHUDBackground\":\"39, 39, 39, 214\",\"BTTActionHUDSlideDirection\":0}'})})\n : callBTT('trigger_action', {json: JSON.stringify({\n 'BTTPredefinedActionType': 254, 'BTTPredefinedActionName': 'Show HUD Overlay', 'BTTHUDActionConfiguration': '{\"BTTActionHUDTitle\":\"⌘Q\",\"BTTActionHUDDetail\":\"Can not quit\",\"BTTActionHUDDuration\":0.9,\"BTTActionHUDBackground\":\"39, 39, 39, 214\",\"BTTActionHUDSlideDirection\":0}'})});\n }\n }\n})();", "BTTAdditionalConfiguration" : "1048584", "BTTEnabled2" : 1, "BTTKeyboardShortcutKeyboardType" : 2601, "BTTRepeatRate" : 0.05, "BTTRepeatDelay" : 0, "BTTUUID" : "66657AB0-19DA-49E4-8D57-60077A1B6734", "BTTTriggerOnDown" : 1, "BTTNotesInsteadOfDescription" : 0, "BTTLayoutIndependentChar" : "ꢓ", "BTTEnabled" : 1, "BTTModifierMode" : 0, "BTTShortcutKeyCode" : 12, "BTTShortcutModifierKeys" : 1048576, "BTTOrder" : 88000, "BTTDisplayOrder" : 0, "BTTAutoAdaptToKeyboardLayout" : 0 } ] } ], "BTTPresetSnapAreas" : [ ] }