Forcing Firefox keyboard shortcuts the hard way


Firefox's Quantum update provides some significant improvements in performance and other general underlying technology things (that I don't fully understand, as I'm not a Mozilla developer). However, in their eagerness to throw away as much work from the community as possible, they crippled the ability of addons to cutomize the interface, instead turning addons into nothing more than glorified greasemonky scripts.

A lot of the interface customizations I want are possible with userChrome.css modifications, which I'm relatively comfortable with doing, it's limited to the specific profile in use, etc. It'd be better if there was a way to automate or any sensible documentation on that, but it's open source, you read the code and figure it out.

On the other hand, Mozilla seems hell-bent on completely removing the ability to change the keyboard shortcuts in any way. There are half-baked solutions that can only change shortcuts within the page, or only work if you're not on a "secure" page, whatever the hell that is. (i.e. it's fine to change the browser's behavior in GMail, but addons aren't allow to change the browser's behavior on the addon page... as if "inconsistently and partially" customizable is what anyone actually wants)

There's some information on how to modify the sources to change keyboard shortcuts, but it doesn't appear to have been updated for the latest releases. Firefox 64, in my case.

Now, since I'm running Gentoo, it's not a terribly difficult thing to patch the source, User patches are well supported, so all I need is a patch that changes the shortcuts how I want. Still not actually configurable, but at least I can make it behave.

listings/newtab.patch (Source)

diff -dupbr firefox-64.0/browser/base/content/ firefox-64.0-edit/browser/base/content/
--- firefox-64.0/browser/base/content/  2018-12-06 21:56:20.000000000 -0500
+++ firefox-64.0-edit/browser/base/content/ 2018-12-26 10:41:18.293000000 -0500
@@ -116,7 +116,7 @@
     <key id="key_newNavigator"
-         modifiers="accel" reserved="true"/>
+         modifiers="accel,shift" reserved="true"/>
     <key id="key_newNavigatorTab" key="&tabCmd.commandkey;" modifiers="accel"
          command="cmd_newNavigatorTabNoEvent" reserved="true"/>
     <key id="focusURLBar" key="&openCmd.commandkey;" command="Browser:OpenLocation"
@@ -293,7 +293,7 @@
     <key id="key_undoCloseTab" command="History:UndoCloseTab" key="&tabCmd.commandkey;" modifiers="accel,shift"/>
-    <key id="key_undoCloseWindow" command="History:UndoCloseWindow" key="&newNavigatorCmd.key;" modifiers="accel,shift"/>
+    <!-- <key id="key_undoCloseWindow" command="History:UndoCloseWindow" key="&newNavigatorCmd.key;" modifiers="accel,shift"/> -->
 #ifdef XP_GNOME
diff -dupbr firefox-64.0/browser/locales/en-US/chrome/browser/browser.dtd firefox-64.0-edit/browser/locales/en-US/chrome/browser/browser.dtd
--- firefox-64.0/browser/locales/en-US/chrome/browser/browser.dtd   2018-12-06 21:56:20.000000000 -0500
+++ firefox-64.0-edit/browser/locales/en-US/chrome/browser/browser.dtd  2018-12-26 10:38:05.298000000 -0500
@@ -104,8 +104,8 @@ These items have the same accesskey but
 <!ENTITY  listAllTabs.label      "List all tabs">
 <!ENTITY tabCmd.label "New Tab">
-<!ENTITY tabCmd.accesskey "T">
-<!ENTITY tabCmd.commandkey "t">
+<!ENTITY tabCmd.accesskey "N">
+<!ENTITY tabCmd.commandkey "n">
 <!-- LOCALIZATION NOTE (openLocationCmd.label): "Open Location" is only
 displayed on OS X, and only on windows that aren't main browser windows, or
 when there are no windows but Firefox is still running. -->

What I want is for the New Tab action to be bound to C-T not C-N and to have New Window (on the off chance I ever use it) moved to C-S-N. (Unbinding entirely the Undo Close Window accelerator. Who uses that?)

Adding rocker mouse guestures would be nice, but I can live without the rest of the changes I've used in previous versions. (Mostly holdovers from when I used Opera.)