搜尋 Mozilla 技術支援網站

防止技術支援詐騙。我們絕對不會要求您撥打電話或發送簡訊,或是提供個人資訊。請用「回報濫用」功能回報可疑的行為。

了解更多

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

  • 5 回覆
  • 4 有這個問題
  • 73 次檢視
  • 最近回覆由 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?

被選擇的解決方法

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.

從原來的回覆中察看解決方案 👍 1

所有回覆 (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

選擇的解決方法

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.