-
Notifications
You must be signed in to change notification settings - Fork 46
feat: add systemd units and plugin groups for tray loader #518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
deepin-bot
merged 1 commit into
linuxdeepin:master
from
yixinshark:feat/tray-plugin-systemd-services
Sep 22, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| { | ||
| "magic": "dsg.config.meta", | ||
| "version": "1.0", | ||
| "contents": { | ||
| "selfMaintenanceTrayPlugins": { | ||
| "value": [ | ||
| "libapplication-tray.so", | ||
| "libbrightness.so", | ||
| "libdatetime.so", | ||
| "libdnd-mode.so", | ||
| "libeye-comfort-mode.so", | ||
| "libmedia.so", | ||
| "libnotification.so", | ||
| "libonboard.so", | ||
| "libshutdown.so", | ||
| "libairplane-mode.so", | ||
| "libbluetooth.so", | ||
| "libdock-network-plugin.so", | ||
| "libdock-wirelesscasting-plugin.so", | ||
| "libkeyboard-layout.so", | ||
| "libpower.so", | ||
| "libsound.so" | ||
| ], | ||
| "serial": 0, | ||
| "flags": [], | ||
| "name": "self maintenance tray plugins", | ||
| "name[zh_CN]": "自维护托盘插件", | ||
| "description": "Tray plugins maintained by their own lifecycle and not restarted on crash. Loaded together in one process group.", | ||
| "description[zh_CN]": "由自身维护生命周期、崩溃后不自动重启的托盘插件,集中在一个进程组中加载。", | ||
| "permissions": "readonly", | ||
| "visibility": "private" | ||
| }, | ||
| "subprojectTrayPlugins": { | ||
| "value": [ | ||
| "libdock-clipboard-plugin.so", | ||
| "libddegrandsearch_dockplugin.so", | ||
| "libdeepin-screen-recorder-plugin.so", | ||
| "libdeepin-system-monitor-plugin.so", | ||
| "libshot-start-plugin.so", | ||
| "libshot-start-record-plugin.so", | ||
| "libdde-disk-mount-plugin.so" | ||
| ], | ||
| "serial": 0, | ||
| "flags": [], | ||
| "name": "subproject tray plugins", | ||
| "name[zh_CN]": "子项目托盘插件", | ||
| "description": "Tray plugins maintained by sibling subprojects, isolated in their own process group.", | ||
| "description[zh_CN]": "由同级子项目维护的托盘插件,独立成组加载以便隔离。", | ||
| "permissions": "readwrite", | ||
| "visibility": "private" | ||
| }, | ||
| "crashProneTrayPlugins": { | ||
| "value": [], | ||
| "serial": 0, | ||
| "flags": [], | ||
| "name": "crash-prone tray plugins", | ||
| "name[zh_CN]": "易于崩溃的托盘插件", | ||
| "description": "Tray plugins known to be unstable, isolated in their own process group so a crash does not affect other plugins.", | ||
| "description[zh_CN]": "已知不稳定的托盘插件,独立成组加载,崩溃时不影响其他插件。", | ||
| "permissions": "readwrite", | ||
| "visibility": "private" | ||
| } | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| // SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. | ||
| // | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
| #include "trayplugingroups.h" | ||
|
|
||
| #include <DConfig> | ||
|
|
||
| #include <QDir> | ||
| #include <QLoggingCategory> | ||
| #include <QScopedPointer> | ||
|
|
||
| Q_LOGGING_CATEGORY(loaderLog, "org.deepin.dde.tray-loader") | ||
|
|
||
| namespace loader { | ||
|
|
||
| namespace { | ||
|
|
||
| const QStringList &pluginDirs() | ||
| { | ||
| // Keep in sync with the directories previously scanned by dde-shell | ||
| // (panels/dock/loadtrayplugins.h). | ||
| static const QStringList dirs = { | ||
| "/usr/lib/dde-dock/plugins/", | ||
| "/usr/lib/dde-dock/plugins/quick-trays/", | ||
| "/usr/lib/dde-dock/plugins/system-trays/" | ||
| }; | ||
|
yixinshark marked this conversation as resolved.
|
||
| return dirs; | ||
| } | ||
|
|
||
| QStringList allPluginPaths() | ||
| { | ||
| QStringList dirs; | ||
| const auto debugPaths = qEnvironmentVariable("TRAY_DEBUG_PLUGIN_PATH"); | ||
| if (!debugPaths.isEmpty()) | ||
| dirs << debugPaths.split(QDir::listSeparator()); | ||
|
|
||
| if (dirs.isEmpty()) | ||
| dirs << pluginDirs(); | ||
|
|
||
| QStringList pluginPaths; | ||
| for (const auto &pluginDir : std::as_const(dirs)) { | ||
| QDir dir(pluginDir); | ||
| if (!dir.exists()) { | ||
| qCWarning(loaderLog) << "The plugin directory does not exist:" << pluginDir; | ||
| continue; | ||
| } | ||
|
|
||
| const auto pluginFileInfos = dir.entryInfoList({"*.so"}, QDir::Files); | ||
| for (const auto &pluginInfo : pluginFileInfos) { | ||
| pluginPaths.append(pluginInfo.absoluteFilePath()); | ||
| } | ||
| } | ||
|
|
||
| return pluginPaths; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| bool isValidGroup(const QString &groupName) | ||
| { | ||
| return groupName == SelfMaintenanceGroup | ||
| || groupName == SubprojectGroup | ||
| || groupName == CrashProneGroup | ||
| || groupName == OtherGroup; | ||
| } | ||
|
|
||
| QStringList pluginPathsForGroup(const QString &groupName, bool *ok) | ||
| { | ||
| // The grouping schema is owned by dde-tray-loader itself (appid | ||
| // org.deepin.dde.tray-loader, config org.deepin.dde.dock.plugin.groups). | ||
| // It supersedes the grouping keys that previously lived in dde-shell's | ||
| // org.deepin.ds.dock.tray schema. | ||
| QScopedPointer<Dtk::Core::DConfig> dConfig(Dtk::Core::DConfig::create( | ||
| "org.deepin.dde.tray-loader", "org.deepin.dde.dock.plugin.groups", QString())); | ||
| if (!dConfig || !dConfig->isValid()) { | ||
| qCWarning(loaderLog) << "Failed to load group config for" << groupName; | ||
| if (ok) *ok = false; | ||
| return {}; | ||
| } | ||
| if (ok) *ok = true; | ||
|
|
||
| const QStringList crashPronePlugins = dConfig->value(CrashProneGroup).toStringList(); | ||
| const QStringList selfMaintenancePlugins = dConfig->value(SelfMaintenanceGroup).toStringList(); | ||
| const QStringList subprojectPlugins = dConfig->value(SubprojectGroup).toStringList(); | ||
|
|
||
| QStringList groupPluginPaths; | ||
| for (const auto &filePath : allPluginPaths()) { | ||
| const QString pluginName = filePath.section("/", -1); | ||
| // Each plugin belongs to exactly one group, with crash isolation taking priority. | ||
| const char *assignedGroup = OtherGroup; | ||
| if (crashPronePlugins.contains(pluginName)) | ||
| assignedGroup = CrashProneGroup; | ||
| else if (selfMaintenancePlugins.contains(pluginName)) | ||
| assignedGroup = SelfMaintenanceGroup; | ||
| else if (subprojectPlugins.contains(pluginName)) | ||
| assignedGroup = SubprojectGroup; | ||
|
|
||
| if (groupName == assignedGroup) | ||
| groupPluginPaths.append(filePath); | ||
| } | ||
|
|
||
| return groupPluginPaths; | ||
| } | ||
|
|
||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // SPDX-FileCopyrightText: 2024 - 2026 UnionTech Software Technology Co., Ltd. | ||
| // | ||
| // SPDX-License-Identifier: GPL-3.0-or-later | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <QStringList> | ||
|
|
||
| namespace loader { | ||
|
|
||
| // Well-known plugin group names. They match the keys of the | ||
| // org.deepin.dde.dock.plugin.groups DConfig schema (owned by dde-tray-loader), | ||
| // which assigns each plugin .so to the process group it should be loaded in. | ||
| inline constexpr auto SelfMaintenanceGroup = "selfMaintenanceTrayPlugins"; | ||
| inline constexpr auto SubprojectGroup = "subprojectTrayPlugins"; | ||
| inline constexpr auto CrashProneGroup = "crashProneTrayPlugins"; | ||
| inline constexpr auto OtherGroup = "otherTrayPlugins"; | ||
|
|
||
| // Whether <groupName> is one of the well-known group names. Used to reject | ||
| // typos in manual invocations early instead of silently loading nothing. | ||
| bool isValidGroup(const QString &groupName); | ||
|
|
||
| // Scan the standard dde-dock plugin directories and return the absolute | ||
| // paths of all plugins that belong to the given group according to the | ||
| // DConfig grouping configuration. Plugins not listed in any configured | ||
| // group fall into OtherGroup. | ||
| // | ||
| // When <ok> is non-null, it is set to false if the grouping config could | ||
| // not be loaded (so callers can distinguish a genuine empty group from a | ||
| // config failure), and to true otherwise. | ||
| QStringList pluginPathsForGroup(const QString &groupName, bool *ok = nullptr); | ||
|
|
||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| [Unit] | ||
| Description=DDE Tray Plugin Loader target | ||
| # Tray plugin processes render into the dock's internal dockplugin Wayland | ||
| # compositor exported by dde-shell. Their lifetime is therefore bound to the | ||
| # dock shell: when the shell stops or crashes, the loader instances are | ||
| # stopped as well and restarted together with the shell. | ||
| BindsTo=dde-shell@DDE.service | ||
| After=dde-shell@DDE.service | ||
| # Stop with the session core without delaying its startup for dock readiness. | ||
| PartOf=dde-session-core.target |
1 change: 1 addition & 0 deletions
1
systemd/dde-tray-loader.target.wants/dde-tray-loader@crashProneTrayPlugins.service
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../dde-tray-loader@.service |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.