feat: sessionFieldOverrides for override Exec key in a given session - #379
Conversation
Reviewer's GuideAdds a DConfig-driven, session-specific override mechanism for desktop file Exec/TryExec and environment variables, wires it through application creation/autostart checks, and introduces supporting SessionOverrideConfig and SessionType helpers with unit tests. Sequence diagram for Exec and Env resolution with session overridessequenceDiagram
participant AMS as ApplicationManager1Service
participant AS as ApplicationService
participant CM as CompatibilityManager
participant SOC as SessionOverrideConfig
AMS->>AS: createApplicationService(...)
AMS->>AMS: getSessionOverrideConfig()
AMS->>AS: shouldBeShown(entry, desktopId, sessionConfig)
AS->>CM: getCompatibilityManager()
AS->>AS: processCompatibility(action, options, execStr)
Note over AS: originalExec = execStr
AS->>CM: getExec(desktopId)
AS->>AS: apply compatibility Exec/env
AS->>AMS: parent().getSessionOverrideConfig()
AS->>SOC: getValue(desktopId, groupKey, DesktopEntryExec)
alt Exec override exists
AS->>SOC: resolveExecValue(overrideExec, originalExec)
AS->>AS: execStr = resolvedExec
end
AS->>SOC: getEnv(desktopId, groupKey)
alt Env overrides not empty
AS->>AS: merge Env into options[EnvKey]
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
c0c75c0 to
ea88ef1
Compare
d189844 to
f7468cd
Compare
c49bc93 to
4ca5876
Compare
|
备注:
desktopid 不允许包含 |
新增 DConfig 配置项,允许为指定会话(例如wayland)覆盖指定desktop文件中 的Exec/TryExec/Icon字段的值. 实际场景为解决部分应用程序默认Exec字段的参数会无法在treeland下表现良 好的问题.Icon字段则为允许应用(低频率)动态更新图标所用 Log:
4ca5876 to
cb7b7fd
Compare
deepin pr auto review★ 总体评分:60分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // src/sessionoverrideconfig.cpp
#include <QRegularExpression>
ApplicationOverrideConfig *SessionOverrideConfig::configFor(const QString &desktopId) const
{
if (m_subpathPrefix.isEmpty())
return nullptr;
// 安全检查:防止路径遍历攻击
static const QRegularExpression validIdRegex("^[a-zA-Z0-9._-]+$");
if (!validIdRegex.match(desktopId).hasMatch()) {
qCWarning(logSessionOverride) << "Invalid desktopId detected, possible path traversal:" << desktopId;
return nullptr;
}
auto it = m_configs.find(desktopId);
if (it != m_configs.end())
return it->second.get();
const auto subpath = u"/"_s % desktopId % m_subpathPrefix;
// 移除不必要的 const_cast,直接使用 mutable 成员
auto config = ApplicationOverrideConfig::create(fromStaticRaw(ApplicationServiceID),
subpath,
this);
if (!config) {
qCWarning(logSessionOverride) << "Failed to create DConfig for subpath:" << subpath;
return nullptr;
}
qCInfo(logSessionOverride) << "Creating DConfig for" << desktopId << "subpath:" << subpath;
QObject::connect(config, &ApplicationOverrideConfig::valueChanged,
this, [this, desktopId](const QString &key) {
if (key == u"Exec"_s || key == u"TryExec"_s || key == u"Icon"_s) {
qCInfo(logSessionOverride) << "Override changed for" << desktopId << "key:" << key;
this->updateOverride(desktopId);
emit this->overrideChanged(desktopId, key);
emit this->configChanged();
}
});
QObject::connect(config, &ApplicationOverrideConfig::configInitializeSucceed,
this, [this, desktopId, config](DTK_CORE_NAMESPACE::DConfig *) {
qCInfo(logSessionOverride) << "Override config initialized for" << desktopId;
this->updateOverride(desktopId);
});
QObject::connect(config, &ApplicationOverrideConfig::configInitializeFailed,
this, [this, desktopId]() {
qCWarning(logSessionOverride) << "Override config initialization failed for" << desktopId;
});
m_configs[desktopId] = std::unique_ptr<ApplicationOverrideConfig>(config);
return config;
} |
|
@BLumia: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: BLumia, ComixHe 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 |
新增 DConfig 配置项,允许为指定会话(例如wayland)覆盖指定desktop文件中
的Exec/TryExec字段的值.
配置格式大致为
/usr/share/dsg/configs/overrides/org.deepin.dde.application-manager/org.deepin.dde.am.appoverride/x11/example.app-id/90-override.json{ "magic": "dsg.config.override", "version": "1.0", "contents": { "Exec": { "value": "notify-send 'test am override'" } } }配置好后使用这个命令验证配置项是否正确:
dde-dconfig get -a org.deepin.dde.application-manager -r org.deepin.dde.am.appoverride -s /x11/example.app-id -k Exec实际场景为解决部分应用程序默认Exec字段的参数会无法在treeland下表现良
好的问题.
Log:
Summary by Sourcery
Introduce session-aware configuration to override desktop file Exec/TryExec and environment fields per session and integrate it into application filtering and autostart handling.
Enhancements:
Tests: