AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1523324
Accepted
anmomu92
anmomu92
Asked: 2024-08-14 18:32:44 +0800 CST2024-08-14 18:32:44 +0800 CST 2024-08-14 18:32:44 +0800 CST

更改 GTK 或 QT 主题时不会自动应用应用主题

  • 772

有问题

我正在使用 xmonad WM,我想添加一个键绑定来切换主题。我已经这样做了,而且似乎有效。

问题是 Brave 或 Firefox 等应用程序不会在运行时更新其主题,我必须关闭并再次打开应用程序才能应用主题。

有人知道发生了什么事吗?

我的配置

$HOME/.config/gtk-3.0/settings.ini我选择通过直接在 GTK 和 QT 配置文件(分别为和$HOME/.config/qt5ct/qt5ct.conf)上覆盖主题来切换主题sed。我在 xmonad 的配置文件中对命令进行了键绑定。

我尝试过

  1. 通过以下方式设置主题:gsettings set org.gnome.desktop.interface gtk-theme "<theme-name>"。
  2. HUP向应用程序发送诸如 或 USR1 的信号:pkill -HUP -x brave
themes
  • 1 1 个回答
  • 23 Views

1 个回答

  • Voted
  1. Best Answer
    anmomu92
    2024-08-23T23:12:22+08:002024-08-23T23:12:22+08:00

    xsettingsd我通过安装包 ( sudo apt install xsettingsd) 并在xmonad.hs配置文件中放置一个通过 更改主题的函数解决了这个问题sed。我使用的整个函数如下:

    toggleTheme :: X ()
    toggleTheme = do
      let themeFile = "/tmp/current_theme"  -- Temporary file to track the theme
      fileExists <- io $ doesFileExist themeFile
      if fileExists
          then do
              -- If the file exists, switch to the dark theme and delete the file
              spawn "sed -i 's#color_scheme_path=/usr/share/qt5ct/colors/airy.conf#color_scheme_path=/usr/share/qt5ct/colors/darker.conf#' ~/.config/qt5ct/qt5ct.conf"
              spawn "sed -i 's/gtk-theme-name=Yaru/gtk-theme-name=Yaru-dark/' ~/.config/gtk-3.0/settings.ini"
              spawn "sed -i 's#Net/ThemeName \"Yaru\"#Net/ThemeName \"Yaru-dark\"#' ~/.config/xsettingsd/xsettingsd.conf"
              spawn "killall -HUP xsettingsd"
              io $ removeFile themeFile  -- Create the file to indicate dark theme
          else do
              -- If the file does not exist, switch to the light theme and create the file
              spawn "sed -i 's#color_scheme_path=/usr/share/qt5ct/colors/darker.conf#color_scheme_path=/usr/share/qt5ct/colors/airy.conf#' ~/.config/qt5ct/qt5ct.conf"
              spawn "sed -i 's/gtk-theme-name=Yaru-dark/gtk-theme-name=Yaru/' ~/.config/gtk-3.0/settings.ini"
              spawn "sed -i 's#Net/ThemeName \"Yaru-dark\"#Net/ThemeName \"Yaru\"#' ~/.config/xsettingsd/xsettingsd.conf"
              spawn "killall -HUP xsettingsd"
              io $ writeFile themeFile ""  -- Create the file to indicate light theme
    

    请注意,我保留了前面的sed命令以防万一,并且在覆盖 xsettingsd 的配置文件后,我让 xsettingsd 使用命令再次重新加载它killall -HUP xsettingsd。

    在同一个xmonad.hs文件中,将该功能绑定到一个键即可。

    ((modm, xK_s), toggleTheme)
    
    • 0

相关问题

  • 如何安装不同的图标?[复制]

  • 每当我在 wine 中安装任何东西时,主题都会混乱

  • 我可以使用哪些工具和技术来制作 GTK 主题?

  • 如何更改 GDM 中的登录屏幕主题?

  • 如何获取和安装更多主题、图标和指针?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve