[Others] Fcitx5 输入法主题不能随系统切换
Tofloor
poster avatar
小骏不抬杠
deepin
2025-03-04 10:45
Author

Fcitx5 输入法的设置菜单里是可以选默认深色主题和浅色主题的,当系统主题切换时,输入法主题应该会随之切换。

咱们的系统切换不了,一直是浅色主题。

系统版本 Deepin V23 正式版。

Reply Favorite View the author
All Replies
luckyBunny
deepin
2025-03-04 14:32
#1

这个貌似是Fcitx上游的问题……确实改不了,好在我本身习惯用深色模式,配个深色主题,也就无所谓了😂
image.png

image.png

Reply View the author
ㅤ旭旭哥
deepin
2025-03-04 17:00
#2
It has been deleted!
ㅤ旭旭哥
deepin
2025-03-04 17:13
#3

可以把默认改成黑的

Reply View the author
哄哄
deepin
2025-03-04 18:45
#4

fcitx5没有把dde的api接入吧,希望dde的开发组去fcitx贡献就可以了

Reply View the author
DebuggerX
deepin
2025-03-04 18:55
#5

如果我没弄错的话,这是因为dde的明暗主题切换时没有按照xdg-desktop-portal标准设置color-scheme:

https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Settings.html

而fcitx5的明暗主题切换就是靠的监听读取 "org.freedesktop.appearance", "color-scheme"

https://github.com/fcitx/fcitx5/blob/38fa94cb4876a41928826772d6478caecb1996cc/src/ui/classic/classicui.cpp#L173-L182

if (dbus()) {
        if (*config_.useDarkTheme) {
            if (!darkModeEntry_ && settingMonitor_) {
                darkModeEntry_ = settingMonitor_->watch(
                    "org.freedesktop.appearance", "color-scheme", parseMessage);
            }
        } else {
            darkModeEntry_.reset();
        }
    }

如果有人能把这个支持上就好了……

Reply View the author
DebuggerX
deepin
2025-03-04 18:57
#6
哄哄

fcitx5没有把dde的api接入吧,希望dde的开发组去fcitx贡献就可以了

dde切换主题写的是 com.deepin.xsettings 的 theme-name,而不是标准的 "org.freedesktop.appearance" 的 "color-scheme",fcitx没道理去一个个兼容DE特有的设置项

Reply View the author
DebuggerX
deepin
2025-03-04 19:06
#7

如果很需要这个功能,可以写个程序或脚本监听dde的主题变化,然后通过dbus给fcitx5发指令切换主题。

我这里有份dart版本的:

import 'dart:io';

import 'package:gsettings/gsettings.dart';

late String lightTheme;
late String dartTheme;

late GSettings xsettings;

main(List args) {
  if (args.length != 2) {
    print('请指定主题名');
    exit(0);
  }

  lightTheme = args.first;
  dartTheme = args.last;

  xsettings = GSettings('com.deepin.xsettings');

  xsettings.keysChanged.listen((event) {
    _setTheme();
  });

  _setTheme();
}

_setTheme() {
  xsettings.get('theme-name').then((value) {
    bool isDark = value.toString().contains('dark');

    Process.runSync(
      'gdbus',
      [
        'call',
        '--session',
        '--dest',
        'org.fcitx.Fcitx5',
        '--object-path',
        '/controller',
        '--method',
        'org.fcitx.Fcitx.Controller1.SetConfig',
        'fcitx://config/addon/classicui',
        "<{'Theme': <'${isDark ? dartTheme : lightTheme}'>}>",
      ],
      runInShell: true,
    );

    print('切换为[${isDark ? dartTheme : lightTheme}]主题');
  });
}

然后把它弄成开机启动,就可以实现自动切换的效果……

Reply View the author