# Firefox

Install Firefox via these packages (adjust for your desired locale):

~~~bash
pacman -S firefox firefox-i18n-de
~~~

## Hardware Acceleration

Utilizing GPU hardware accelerated decoding of video content results in smoother playback of HD/4K content, while reducing CPU load and power draw (important to save on battery on laptops).

To ensure Firefox uses hardware decoding verify the following:

* The necessary VA-API drivers are installed (see: [Graphics Cards](/books/arch-linux/page/graphics-cards))
* Navigate to `about:support` and verify that *Compositing* says *WebRender* (*WebRender Software* will **not** work)

#### Verify hardware video decoding

To verify Firefox is actually using VA-API to decode video you can launch it with the following command:

~~~bash
MOZ_LOG="FFmpegVideo:5" firefox 2>&1 | grep 'VA-API'
~~~

Start playing some video in Firefox and watch the logs on your terminal. If your log output reads something like the following video decoding via VA-API is working.

~~~
[RDD 97685: MediaPDecoder #1]: D/FFmpegVideo FFVPX: Initialising VA-API FFmpeg decoder
[RDD 97685: MediaPDecoder #2]: D/FFmpegVideo FFVPX:   VA-API FFmpeg init successful
[RDD 97685: MediaPDecoder #2]: D/FFmpegVideo FFVPX: Choosing FFmpeg pixel format for VA-API video decoding.
[RDD 97685: MediaPDecoder #1]: D/FFmpegVideo FFVPX:   VA-API FFmpeg init successful
[RDD 97685: MediaPDecoder #2]: D/FFmpegVideo FFVPX: VA-API Got one frame output with pts=0 dts=0 duration=40000 opaque=-9223372036854775808
[RDD 97685: MediaPDecoder #1]: D/FFmpegVideo FFVPX: Initialising VA-API FFmpeg decoder
[RDD 97685: MediaPDecoder #1]: D/FFmpegVideo FFVPX:   VA-API FFmpeg init successful
[RDD 97685: MediaPDecoder #1]: D/FFmpegVideo FFVPX: VA-API Got one frame output with pts=40000 dts=40000 duration=40000 opaque=-9223372036854775808
[RDD 97685: MediaPDecoder #2]: D/FFmpegVideo FFVPX: VA-API Got one frame output with pts=80000 dts=80000 duration=40000 opaque=-9223372036854775808
[RDD 97685: MediaPDecoder #2]: D/FFmpegVideo FFVPX: VA-API Got one frame output with pts=120000 dts=120000 duration=40000 opaque=-9223372036854775808
~~~

## Customization

<p class="callout warning"><strong>ATTENTION:</strong> Firefox version 147 introduced support for the XDG Base Directory Specification. Firefox will not migrate old profiles to the new directory structure. If you've set up Firefox before version 147, the previous location for all things Firefox remains <code>~/.mozilla/</code>. This article assumes a fresh install.</p>

Most customizations can be done in `about:config` from the browser UI. Settings that deviate from defaults are saved to `~/.config/mozilla/firefox/<user-profile>/prefs.js`.

It is possible to pre-set certain settings in a separate `user.js` file in the same directory to override defaults. Both files have the same syntax:

~~~js
user_pref("setting.key.goes.here", value)
~~~

### Autoplay in background

Firefox prevents autoplay for media of tabs that aren't currently active, which causes apps like Plex to take very long to skip to the next track after the current one has ended. The following setting in `about:config` can be used to disable this behavior:

| Setting key                                | Value   | Description                                      |
|--------------------------------------------|---------|--------------------------------------------------|
| `media.block-autoplay-until-in-foreground` | `false` | Enable autoplay when tab is not currently active |

Or via `user.js`:

~~~js
user_pref("media.block-autoplay-until-in-foreground", false)
~~~


## KDE Plasma Integration

For better integration of Firefox into the KDE Plasma desktop, install the Plasma Integration add-on either via the [Mozilla Add-on page](https://addons.mozilla.org/firefox/addon/plasma-integration/). It enables rich notifications support and download progress integration into the notification area of KDE Plasma.

To prevent duplicate entries in the Media Player widget or tray icon, set `media.hardwaremediakeys.enabled` to `false`. This disables the media entry from Firefox itself and only uses the one from the Plasma integration add-on.

Or via `user.js`:

~~~js
user_pref("media.hardwaremediakeys.enabled", false)
~~~

## XDG Portal Integrations

By default, Firefox uses GTK file and print dialogs, even on KDE. To change this to KDE native dialogs navigate to `about:config` and change the appropriate `widget.use-xdg-desktop-portal` settings to `1` (default is `2` which equates to auto-detection).

The settings are as follows:

| Setting Key                                  | Description                                                                        |
| -------------------------------------------- | ---------------------------------------------------------------------------------- |
| `widget.use-xdg-desktop-portal.file-picker`  | Use file dialogs native to current desktop environment                             |
| `widget.use-xdg-desktop-portal.location`     | Use GeoLocation services of current desktop environment                            |
| `widget.use-xdg-desktop-portal.mime-handler` | Use MIME handler of current desktop environment for opening files in external apps |
| `widget.use-xdg-desktop-portal.open-uri`     | Use desktop environment for invoking local apps from websites                      |
| `widget.use-xdg-desktop-portal.settings`     | Use desktop environment settings for dark/light mode among other things            |

Or via `user.js`:

~~~js
user_pref("widget.use-xdg-desktop-portal.file-picker", 1);
user_pref("widget.use-xdg-desktop-portal.location", 1);
user_pref("widget.use-xdg-desktop-portal.mime-handler", 1);
user_pref("widget.use-xdg-desktop-portal.open-uri", 1);
user_pref("widget.use-xdg-desktop-portal.settings", 1);
~~~

## Disable AI Integrations

Mozilla introduced multiple AI integrations, despite user pushback. To disable these set the following settings in `user.js`:

~~~js
user_pref("browser.ml.chat.enabled", false);
user_pref("browser.ml.chat.menu", false);
user_pref("browser.ml.chat.page.footerBadge", false);
user_pref("browser.ml.chat.page.menuBadge", false);
user_pref("browser.ml.chat.page", false);
user_pref("browser.ml.enable", false);
user_pref("browser.ml.linkPreview.enabled", false);
user_pref("browser.ml.pageAssist.enabled", false);
user_pref("browser.ml.smartAssist.enabled", false);
user_pref("browser.search.visualSearch.featureGate", false);
user_pref("browser.tabs.groups.smart.enabled", false);
user_pref("browser.tabs.groups.smart.userEnabled", false);
user_pref("browser.urlbar.quicksuggest.mlEnabled", false);
user_pref("extensions.ml.enabled", false);
user_pref("pdfjs.enableAltText", false);
user_pref("places.semanticHistory.featureGate", false);
user_pref("sidebar.revamp", false);
~~~