Die Funktionalität dieser Website ist durch Wartungsarbeiten eingeschränkt, die Ihr Erlebnis verbessern sollen. Wenn ein Artikel Ihr Problem nicht löst und Sie eine Frage stellen möchten, können Sie unsere Gemeinschaft über @FirefoxSupport auf Twitter, /r/firefox oder Reddit fragen.

Hilfe durchsuchen

Vorsicht vor Support-Betrug: Wir fordern Sie niemals auf, eine Telefonnummer anzurufen, eine SMS an eine Telefonnummer zu senden oder persönliche Daten preiszugeben. Bitte melden Sie verdächtige Aktivitäten über die Funktion „Missbrauch melden“.

Weitere Informationen

How to set the default zoom level depending on the screen under Linux?

  • 5 Antworten
  • 4 haben dieses Problem
  • 23 Aufrufe
  • Letzte Antwort von vinc17

more options

From the same account, I can use different kinds of screens: low dpi and high dpi. I'd like to have the font size (and more generally, zoom level) right for each screen.

To set the default zoom level, one can set layout.css.devPixelsPerPx, but one can only set it to some fixed value, which is not OK, because I would like the value to depend on the environment (like for the font size in the menu, which is always OK, as it depends on the Xft.dpi X11 resource).

Note: I have multiple profiles, so that it is not even possible to write a wrapper that would modify the prefs.js file, because I don't know in advance which file I would need to modify.

What can I do?

From the same account, I can use different kinds of screens: low dpi and high dpi. I'd like to have the font size (and more generally, zoom level) right for each screen. To set the default zoom level, one can set layout.css.devPixelsPerPx, but one can only set it to some fixed value, which is not OK, because I would like the value to depend on the environment (like for the font size in the menu, which is always OK, as it depends on the Xft.dpi X11 resource). Note: I have multiple profiles, so that it is not even possible to write a wrapper that would modify the prefs.js file, because I don't know in advance which file I would need to modify. What can I do?

Ausgewählte Lösung

A possibility would to to use the mozilla.cfg file in the Firefox program folder. This file can contain JavaScript that runs with full chrome privileges and it it not difficult the set the layout.css.devPixelsPerPx pref to a value that is correct for the currently attached screen. You would have to find out how to calculate the screen dimensions.

Diese Antwort im Kontext lesen 👍 1

Alle Antworten (5)

more options

if you want to set the text size/pixel density in firefox different from that of your system's settings like it was handled in prior versions, enter about:config into the firefox address bar (confirm the info message in case it shows up) & search for the preference named layout.css.devPixelsPerPx. double-click it and change its value to 1.0 (or any other zoom factor that fits your purpose; -1.0 is the default value and will adhere to the system settings).

more options

Ausgewählte Lösung

A possibility would to to use the mozilla.cfg file in the Firefox program folder. This file can contain JavaScript that runs with full chrome privileges and it it not difficult the set the layout.css.devPixelsPerPx pref to a value that is correct for the currently attached screen. You would have to find out how to calculate the screen dimensions.

more options

cor-el said

Thanks. This works. More precisely I have in the application directory defaults/pref/default-prefs.js with:

pref("general.config.obscure_value", 0); pref("general.config.filename", "firefox.cfg");

And firefox.cfg contains:

// IMPORTANT: Start your code on the 2nd line var hdef = getenv("X11_HDEF"); if (hdef >= 2400) {

 pref("layout.css.devPixelsPerPx", "1.77");

} else {

 pref("layout.css.devPixelsPerPx", "-1.0");

}

My configuration system makes sure that the X11_HDEF environment variable is up-to-date, even when using GNU screen and recalling a session from another machine via SSH.

The only minor problem is that while default-prefs.js can be put under the profiles, firefox.cfg must be in the application directory (I did several tests with strace), which first means that I need to install Firefox under my $HOME, but also I fear that the file is not kept after an upgrade (I have not tried, so I'm not sure); however if this is the case and I'm annoyed by that, I could reinstall it automatically.

more options

You can install Firefox anywhere. It doesn't have to be in the home directory (I install under usr/local) as long as the mozilla.cfg file is in the main application directory where the firefox startup script is located and the script to specify using the mozilla.cfg in the defaults/pref directory.

The defaults/pref directory also stores the channel-prefs.js file and is never affected by an update (only installing a full version could).

more options

I meant for machines shared by several users (who are not admins), in particular on a network with heterogeneous machines and a NFS-mounted home.