Repository navigation
fix: set XDG_CURRENT_DESKTOP=DDE before Xsession.d runs - #250
Merged
Merged
Conversation
Reviewer's GuideConfigurationSet the DDE desktop identity through session metadata and an early Xsession fallback so portal services receive it before activation-environment synchronization.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
mhduiy
reviewed
Nov 23, 2026
1. Declare DesktopNames=DDE so LightDM sets the desktop identity before Xsession. 2. Prevent stale values from the systemd user environment from overriding it. 3. Default to DDE when launching dde-session without a desktop identity. Log: Set the DDE desktop identity before Xsession syncs the activation environment. Influence: Early portals can use the DDE FileChooser. fix(session): 在 Xsession 前设置桌面标识 1. 声明 DesktopNames=DDE,让 LightDM 在进入 Xsession 前设置桌面标识。 2. 防止 systemd 用户环境中的旧值覆盖当前桌面标识。 3. 启动 dde-session 时若桌面标识为空,则补为 DDE。 Log: 在 Xsession 同步激活环境前设置 DDE 桌面标识。 PMS: BUG-382063 Influence: 提前启动的门户可使用 DDE 文件选择器。
mhduiy
force-pushed
the
fix/xsession-desktop-names
branch
from
November 23, 2026 05:32
c2a12e1 to
72fd401
Compare
mhduiy
approved these changes
Nov 23, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: hualet, mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
|
@hualet commit msg 我直接修改了,修复验证没问题,直接合并了 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题现象
在 X11 会话下完成系统升级并重启登录后,依赖 XDG Desktop Portal(
org.freedesktop.portal.Settings->org.freedesktop.appearance/color-scheme)的 Electron / Chromium 应用(如 ChatGPT 桌面端、Chrome 等)不再跟随系统深色/浅色主题设置:org.freedesktop.portal.Desktop的org.freedesktop.portal.Settings.Read('org.freedesktop.appearance', 'color-scheme')始终返回uint32 0(No Preference),切换系统深浅色也没有SettingChanged通知;org.deepin.dde.Appearance1(GtkTheme="deepin-dark")、org.deepin.dde.XSettings1(Net/ThemeName="deepin-dark"),以及直接调用org.freedesktop.impl.portal.desktop.dde,均正常返回uint32 1(Prefer Dark);xdg-desktop-portal-dde.service处于inactive (dead),而xdg-desktop-portal-gtk.service被拉起并接管了Settings/FileChooser等接口(其读取 GNOME gsettingsorg.gnome.desktop.interface color-scheme,在 deepin 下始终为'default')。手动执行
systemctl --user restart xdg-desktop-portal后立即恢复正常。根因分析
通过开机登录阶段的
journalctl --user与/proc/<pid>/environ还原完整时序:/usr/share/xsessions/deepin.desktop缺少DesktopNames=DDELightDM 启动 X11 会话执行
/etc/X11/Xsession.d/*时,环境变量中尚未设置XDG_CURRENT_DESKTOP(要等到最后的99x11-common_start启动dde-session后,由EnvironmentsManager::init()才注入)。20dbus_xdg-runtime与95dbus_update-activation-env同步时缺少XDG_CURRENT_DESKTOP此时执行
dbus-update-activation-environment --systemd ...导入到 D-Bus activation environment 和systemd --user的环境中不包含XDG_CURRENT_DESKTOP。98deepin-upgrade-check抢在dde-session之前激活了xdg-desktop-portal/etc/X11/Xsession.d/98deepin-upgrade-check(deepin-update-ui)在检测到/tmp/deepin_update_option.json后,会阻塞执行/usr/bin/dde-update --wait(Qt 应用)。dde-update启动即通过 D-Bus 激活org.freedesktop.portal.Desktop(xdg-desktop-portal.service):xdg-desktop-portal启动环境缺少XDG_CURRENT_DESKTOP,永久回退至gtk.portal因为
xdg-desktop-portal进程环境中没有XDG_CURRENT_DESKTOP,无法匹配/usr/share/xdg-desktop-portal/dde-portals.conf(default=dde)及dde.portal中的UseIn=DDE,于是记录:Settings/FileChooser等后端永久绑定到xdg-desktop-portal-gtk。dde-session启动再导入XDG_CURRENT_DESKTOP=DDE为时已晚虽然
systemctl --user show-environment事后已经包含XDG_CURRENT_DESKTOP=DDE,但常驻的xdg-desktop-portal不会重载 backend,导致整个会话期间一直走错误的 portal 后端。解决思路与变更内容
采用标准 XDG/Xsession 机制,在进入
Xsession.d的最早期即确立XDG_CURRENT_DESKTOP=DDE,确保后续已有的20dbus_xdg-runtime和95dbus_update-activation-env自动将其同步给 D-Bus 与systemd --user:misc/xsessions/deepin.desktop.inType=Application和DesktopNames=DDE(符合 freedesktop Desktop Entry 规范;LightDM/GDM/SDDM 等显示管理器会据此在进入/etc/X11/Xsession之前即设置XDG_CURRENT_DESKTOP=DDE,且仅作用于 DDE 会话,不污染同机其他桌面环境)。misc/Xsession.d/00deepin-dde-envXDG_CURRENT_DESKTOP加入EXCLUDED_ENV,避免从systemd --user导入环境时被上一次会话残留的旧值覆盖;if [ "$1" = "/usr/bin/dde-session" ]分支中增加兜底:若XDG_CURRENT_DESKTOP为空则导出XDG_CURRENT_DESKTOP="DDE",兼容不支持DesktopNames的显示管理器或启动方式。关于 #245 的补充说明
#245 试图通过
graphical-session-pre.target.wants新增dde-session-environment.service注入XDG_CURRENT_DESKTOP=DDE,存在两点局限:98deepin-upgrade-check(dde-update)场景下,D-Bus 按需激活xdg-desktop-portal.service发生在dde-session启动之前,此时graphical-session-pre.target尚未被拉起,因此该 service 仍来不及执行;graphical-session-pre.target.wants下会在用户登录同机的其他非 DDE 桌面环境时也强制写入XDG_CURRENT_DESKTOP=DDE。本 PR 直接从
deepin.desktop+00deepin-dde-env源头解决,无需新增额外 systemd unit,既覆盖Xsession.d阶段的早期 portal 激活,又严格限定在 DDE 会话内生效。验证
sh -n misc/Xsession.d/00deepin-dde-env语法检查通过;00deepin-dde-env导出的变量(如原有的QT_QPA_PLATFORM="dxcb;xcb")已实测在98deepin-upgrade-check激活的xdg-desktop-portal进程/proc/<pid>/environ中可见,确认20dbus_xdg-runtime/95dbus_update-activation-env在98deepin-upgrade-check之前完成同步。Summary by Sourcery
Set XDG_CURRENT_DESKTOP to DDE early in X11 sessions so XDG Desktop Portal consistently selects the DDE backend.
Bug Fixes:
Enhancements:
Tests:
Ref: #251 — 同步到 U3 分支(
develop/2500u3)