Firefox从哪里获得系统主题?

发布于 2025-02-03 17:24:47 字数 1531 浏览 3 评论 0原文

我正在编写一个bash脚本在必要时在黑暗和光线之间切换系统主题(在Linux Mint 20.3上)。我可以使它适用于整个操作系统主题,终端主题和Flatpak上的一些GNOME应用程序。

因此,我希望Mozilla Firefox将自动切换主题,因为它的主题已设置为System主题。但是,Firefox主题不会改变。如果有人可以将我指向正确的方向,那将是有帮助的。

简而言之,我正在寻找以下至少一个:

  1. Firefox确定Linux Mint上系统主题的方式。
  2. 这些命令强迫Firefox遵循特定主题。

提前致谢。这是我的bash脚本:

#!/bin/bash
if [ $# -eq 0 ]
then
    echo Current Theme: $(gsettings get org.cinnamon.theme name)
elif [ $1 == "dark" ]
then
    gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-dark'
    flatpak override --user --env=GTK_THEME='Yaru-dark'
    gsettings set org.cinnamon.theme name 'Mint-Y-Dark'
    gsettings set org.cinnamon.desktop.interface gtk-theme "Mint-Y-Dark"
    gsettings set org.cinnamon.desktop.wm.preferences theme "Mint-Y-Dark"
    gsettings set org.cinnamon.desktop.interface icon-theme 'Mint-Y-Dark'
    gsettings set org.gnome.Terminal.ProfilesList default f02cd96e-20b4-4146-a6aa-75f5da6a65b2 
elif [ "$1" = "light" ]
then
    gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-light'
    flatpak override --user --env=GTK_THEME='Yaru-light'
    gsettings set org.cinnamon.theme name 'Mint-Y'
    gsettings set org.cinnamon.desktop.interface gtk-theme "Mint-Y"
    gsettings set org.cinnamon.desktop.wm.preferences theme "Mint-Y"
    gsettings set org.cinnamon.desktop.interface icon-theme 'Mint-Y'
    gsettings set org.gnome.Terminal.ProfilesList default b1dcc9dd-5262-4d8d-a863-c897e6d979b9
else
    echo "Unknown argument"
fi

I am writing a bash script to switch system theme between dark and light whenever necessary (on Linux Mint 20.3). I could make it work for the overall OS theme, the terminal theme, and some gnome applications on flatpak.

With this, I expected that Mozilla Firefox will switch theme automatically, as its theme has been set to System theme. However, the Firefox theme does not change. It would be helpful if someone could point me in the right direction to implement this.

In short, I am looking for at least one of the following:

  1. The manner in which Firefox determines the system theme on Linux Mint.
  2. The commands to force Firefox to follow a particular theme.

Thanks in advance. Here is my bash script:

#!/bin/bash
if [ $# -eq 0 ]
then
    echo Current Theme: $(gsettings get org.cinnamon.theme name)
elif [ $1 == "dark" ]
then
    gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-dark'
    flatpak override --user --env=GTK_THEME='Yaru-dark'
    gsettings set org.cinnamon.theme name 'Mint-Y-Dark'
    gsettings set org.cinnamon.desktop.interface gtk-theme "Mint-Y-Dark"
    gsettings set org.cinnamon.desktop.wm.preferences theme "Mint-Y-Dark"
    gsettings set org.cinnamon.desktop.interface icon-theme 'Mint-Y-Dark'
    gsettings set org.gnome.Terminal.ProfilesList default f02cd96e-20b4-4146-a6aa-75f5da6a65b2 
elif [ "$1" = "light" ]
then
    gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-light'
    flatpak override --user --env=GTK_THEME='Yaru-light'
    gsettings set org.cinnamon.theme name 'Mint-Y'
    gsettings set org.cinnamon.desktop.interface gtk-theme "Mint-Y"
    gsettings set org.cinnamon.desktop.wm.preferences theme "Mint-Y"
    gsettings set org.cinnamon.desktop.interface icon-theme 'Mint-Y'
    gsettings set org.gnome.Terminal.ProfilesList default b1dcc9dd-5262-4d8d-a863-c897e6d979b9
else
    echo "Unknown argument"
fi

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

踏月而来 2025-02-10 17:24:47

您正在寻找的答案可能很简单:

gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'

The answer you are looking for might be simply:

gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
千纸鹤带着心事 2025-02-10 17:24:47

不确定这种方式,但我通常会通过在〜/.local/.local/.local/share/applications/中编辑相应的桌面文件来强制强制强制,例如〜/.local/.local/.local/share/applications/firefox.desktop 并将编辑编辑exec行将列出以下内容,以强制Adwaita主题的轻版本,例如:

Exec=env GTK_THEME=Adwaita:light bash -c '/usr/bin/firefox-nightly %u'
Exec=env GTK_THEME=Adwaita:light bash -c '/usr/bin/firefox-nightly --new-window %u'
Exec=env GTK_THEME=Adwaita:light bash -c '/usr/bin/firefox-nightly --private-window %u'

如果您没有相应的文件,请在>中复制文件/usr/share/applications/喜欢/usr/share/applications/firefox.desktop 目录,然后编辑复制版本 - 或将桌面文件复制到/usr/usr/local/applications/,然后编辑该文件以申请所有用户。

但是,应该指出的是,我认为这仅对上下文菜单,窗口小部件选项卡,默认网站在可用时默认网站浅色主题以及窗口按钮,因为整个Firefox主题与GTK主题无关。我相信“使用系统主题”主要是指默认网站偏好,并且再次提到了上下文菜单和窗口按钮之类的东西。

有关更多控制,请在中搜索:config为“ GTK”搜索,这将在Firefox中显示与使用系统主题有关的其他一些设置,尽管这些设置再次与小部件和上下文菜单有关。

Not sure about the manner but I typically force by editing the corresponding desktop file in ~/.local/share/applications/ like ~/.local/share/applications/firefox.desktop and set edit the Exec lines to the following, to force the light version of Adwaita theme, for example:

Exec=env GTK_THEME=Adwaita:light bash -c '/usr/bin/firefox-nightly %u'
Exec=env GTK_THEME=Adwaita:light bash -c '/usr/bin/firefox-nightly --new-window %u'
Exec=env GTK_THEME=Adwaita:light bash -c '/usr/bin/firefox-nightly --private-window %u'

If you don't have a corresponding file, then either copy the file in /usr/share/applications/ like /usr/share/applications/firefox.desktop to the ~/.local/share/applications/ directory and then edit the copied version — or copy the desktop file over to /usr/local/applications/ and then edit that file to apply for all users.

It should be noted, however, that I think this only has an effect on like the context menus, widget tabs, default website light dark themes when available and possibly the window buttons as the overall firefox theme is independent of the gtk theme. I believe the "use system theme" mostly refers to default website preferences and again, stuff like context menus and window buttons.

For more control, search in about:config for "gtk" and this will show a few additional settings in firefox related to using the system theme although again, these are mostly related to widgets and context menus.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文