Skip to content

Conversation

@Glavo
Copy link
Member

@Glavo Glavo commented Jan 24, 2026

No description provided.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

为 Linux 平台增加通过 dbus-send(xdg-desktop-portal Settings API)读取系统 color-scheme,从而在“自动”主题亮度模式下更准确跟随系统深色/浅色设置。

Changes:

  • Themes.getDefaultBrightness() 中新增 Linux 分支,通过 dbus-send 调用 org.freedesktop.portal.Settings.Read 获取 org.freedesktop.appearance color-scheme
  • 解析返回值并映射到 Brightness.DARK/LIGHT,失败时记录 warning 日志
  • 增加相关 imports(Path, FileUtils, LOG

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +133 to +137
String[] result = SystemUtils.run(
FileUtils.getAbsolutePath(dbusSend),
"--session",
"--print-reply=literal",
"--reply-timeout=1000",
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This runs an external process synchronously inside getDefaultBrightness(), which is used by a JavaFX ObjectBinding (computeValue() -> getBrightness()), so it will typically execute on the FX thread. SystemUtils.run(...) can block up to 15s (see HMCLCore/.../SystemUtils.java:98-103), which risks noticeable UI freezes on Linux if dbus-send hangs. Consider enforcing a much shorter overall wait (e.g., Process.waitFor with a small timeout and then destroy the process) or moving the D-Bus query off the FX thread and caching the result before bindings are evaluated.

Copilot uses AI. Check for mistakes.
"org.freedesktop.portal.Settings.Read",
"string:org.freedesktop.appearance",
"string:color-scheme"
).trim().split(" ");
Copy link

Copilot AI Jan 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trim().split(" ") only splits on single space characters and will behave poorly with other whitespace (tabs/newlines) and with the multi-space indentation dbus-send commonly prints. To make theme detection more robust, split on \\s+ (or parse the trailing integer via a regex) before interpreting the last token as the color-scheme value.

Suggested change
).trim().split(" ");
).trim().split("\\s+");

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant