diff --git a/src/background.ts b/src/background.ts index 3c12631f..6e40954f 100644 --- a/src/background.ts +++ b/src/background.ts @@ -244,6 +244,11 @@ omnibox.init() // }}} +browser.commands.onCommand.addListener((command_name: string) => { + if (command_name !== "escape_hatch") return + excmds_background.escapehatch() +}) + // {{{ Obey Mozilla's orders https://github.com/tridactyl/tridactyl/issues/1800 native.unfixamo() diff --git a/src/excmds.ts b/src/excmds.ts index 3c797c07..799dd2cd 100644 --- a/src/excmds.ts +++ b/src/excmds.ts @@ -2936,6 +2936,10 @@ export async function shellescape(...quoteme: string[]) { * Magic escape hatch: return to a tab in the current window where Tridactyl can run, making such a tab if it doesn't currently exist. * * Only useful if called from a background context, e.g. at the end of an RC file to ensure that when you start the browser you don't get trapped on an about: page. + * + * By default, bound to `` via the commands API which may be changed via about:addons, the cog icon in the top right, then "Manage Extension Shortcuts" + * + * */ //#background export async function escapehatch() { diff --git a/src/manifest.json b/src/manifest.json index b792aef3..d60b32f1 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -15,6 +15,14 @@ "chrome_url_overrides": { "newtab": "static/newtab.html" }, + "commands": { + "escape_hatch": { + "suggested_key": { + "default": "Ctrl+Comma" + }, + "description": "Focus or create a tab in which Tridactyl can run" + } + }, "content_scripts": [ { "matches": [ @@ -75,4 +83,4 @@ "omnibox": { "keyword": "tri" } -} \ No newline at end of file +}