Disable/Change Firefox Safe Mode Hotkey (Shift)
Asked Answered
S

3

6

Is there any way to change the firefox shift hotkey that makes firefox start in safe mode? I've set up some unit tests using Selenium and PHPUnit, but if I'm working on the machine while the tests are running then I frequently find I'm pressing shift as I type (holding shift as I select blocks of code is another big offender). This causes the test to fail (and time out) even if you click past the safe mode prompt that pops up.

Is there a way to disable this hot key, or change the key to something that I'd use less often?

Spherics answered 11/4, 2012 at 17:33 Comment(1)
This is terrible. Try putting Firefox in the Windows quicklaunch position 1. WindowsKey+1 will launch Firefox. WindowsKey+Shift+1 is Windows standard for launching another instance of the process. Well, for Firefox, it simply launches in safe mode. They're shooting themselves in the foot, because now it interrupts standard process, and I'll just use Opera instead.Slip
R
4

I've also met with this problem and didn't find a solution. It seems that it is still an open issue: Mozilla Forums thread, Bug 653410, Bug 644175 and so on. As a workaround you can install firefox 3.6 as this feature was implemented since firefox 4, but probably this will not suite you.

Recountal answered 11/4, 2012 at 21:5 Comment(1)
Thanks. If anyone else finds this as they are having the same problem, could you register your issue on the "Mozilla Forums thread" above?Spherics
K
4

Mozilla finally added an environment variable to control this behavior. Unfortunately, configuring this environment variable in a way that applies to the overall graphical system, rather than merely a bash session, is a bit difficult. This used to be done via /etc/launchd.conf, but macOS dropped support for this in v10.10. Fortunately, systemctl offers a .plist file system which can define run programs and define system-wide environment variables at boot, so I published this working .plist file, with instructions for installing and removing it:

https://github.com/mcandre/dotfiles/blob/master/setenv.MOZ_DISABLE_SAFE_MODE_KEY.plist

This is awesome for me, because I like to launch my web browser from anywhere in the GUI with Control+Alt+G via QuickSilver, which of course includes the Alt modifier that Firefox tends to interpret as signaling safe mode.

Konstance answered 12/11, 2017 at 19:2 Comment(1)
Thanks, that's a very good answer (and a working one!). I also used to launching Firefox via a keyboard shortcut that contains an alt modifier.Cusp
P
0

Until Bug 653410 is fixed, the best workaround I can come up with is to detect when safe mode is launched and handle it in the best way fit for your particular purposes. This may mean killing the Firefox process and launching again, or it may mean warning the user, or both.

When Firefox is launched into safe mode, it writes "LastVersion=Safe Mode" to its compatibility.ini file in its profile directory. An example C# function to watch for this is given below.

    FileSystemWatcher safeModeWatcher;

    private void watchSafeMode()
    {
        string profiles = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Mozilla", "Firefox", "Profiles");
        string defaultProfile = Directory.GetDirectories(profiles, "*default*")[0];
        safeModeWatcher = new FileSystemWatcher(defaultProfile, "compatibility.ini");
        safeModeWatcher.NotifyFilter = NotifyFilters.LastWrite;
        safeModeWatcher.Changed += delegate(object s, FileSystemEventArgs e)
        {
            if (File.ReadAllText(e.FullPath).Contains("LastVersion=Safe Mode"))
            {
                // safe mode!
                System.Diagnostics.Trace.WriteLine("safe mode detected!");
                // TODO kill Firefox and launch again, or whatever makes sense for you
            }
        };
        safeModeWatcher.EnableRaisingEvents = true;
        // ...
        // TODO Dispose safeModeWatcher when done
    }
Privation answered 25/11, 2013 at 20:10 Comment(1)
Note you can now add an environment variable to disable the safe mode on Shift feature. set MOZ_DISABLE_SAFE_MODE_KEY=1Privation

© 2022 - 2024 — McMap. All rights reserved.