为提升您的使用体验,本站正在维护,部分功能暂时无法使用。如果本站文章无法解决您的问题,您想要向社区提问的话,请到 Twitter 上的 @FirefoxSupport 或 Reddit 上的 /r/firefox 提问,我们的支持社区将会很快回复您的疑问。

搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

详细了解

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

  • 5 个回答
  • 4 人有此问题
  • 23 次查看
  • 最后回复者为 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.