feat: add GIO_LAUNCHED_DESKTOP_FILE to runtime envs
add hooks for dde-dock Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
parent
3b2674023c
commit
1b4fb5551d
@ -27,6 +27,7 @@ find_package(Threads REQUIRED)
|
|||||||
|
|
||||||
set(APP_LAUNCH_HELPER_BIN app-launch-helper)
|
set(APP_LAUNCH_HELPER_BIN app-launch-helper)
|
||||||
set(APP_UPDATE_NOTIFIER_BIN app-update-notifier)
|
set(APP_UPDATE_NOTIFIER_BIN app-update-notifier)
|
||||||
|
set(AM_LIBEXEC_DIR ${CMAKE_INSTALL_LIBEXECDIR}/deepin/application-manager)
|
||||||
|
|
||||||
if(DDE_AM_USE_DEBUG_DBUS_NAME)
|
if(DDE_AM_USE_DEBUG_DBUS_NAME)
|
||||||
add_compile_definitions(-DDDE_AM_USE_DEBUG_DBUS_NAME)
|
add_compile_definitions(-DDDE_AM_USE_DEBUG_DBUS_NAME)
|
||||||
|
@ -14,4 +14,4 @@ target_include_directories(${APP_LAUNCH_HELPER_BIN} PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
install(TARGETS ${APP_LAUNCH_HELPER_BIN} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/deepin/application-manager/)
|
install(TARGETS ${APP_LAUNCH_HELPER_BIN} DESTINATION ${AM_LIBEXEC_DIR})
|
||||||
|
@ -11,4 +11,4 @@ target_include_directories(${APP_UPDATE_NOTIFIER_BIN} PRIVATE
|
|||||||
)
|
)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
install(TARGETS ${APP_UPDATE_NOTIFIER_BIN} DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/deepin/application-manager/)
|
install(TARGETS ${APP_UPDATE_NOTIFIER_BIN} DESTINATION ${AM_LIBEXEC_DIR})
|
||||||
|
2
debian/dde-application-manager.install
vendored
2
debian/dde-application-manager.install
vendored
@ -4,4 +4,4 @@ usr/lib/*
|
|||||||
usr/libexec/*
|
usr/libexec/*
|
||||||
usr/share/dbus-1/*
|
usr/share/dbus-1/*
|
||||||
usr/share/dsg/*
|
usr/share/dsg/*
|
||||||
|
usr/share/deepin/dde-application-manager/hooks.d/*
|
||||||
|
@ -8,7 +8,7 @@ hook 允许系统组件在应用启动前对应用的运行时环境做出配置
|
|||||||
|
|
||||||
## 配置文件
|
## 配置文件
|
||||||
|
|
||||||
hook 的配置文件需要放在'/usr/share/deepin/dde-application-manager/hook.d/'下,文件名必须符合以下规范:
|
hook 的配置文件需要放在'/usr/share/deepin/dde-application-manager/hooks.d/'下,文件名必须符合以下规范:
|
||||||
- 以数字开头,作为hook的顺序标识。
|
- 以数字开头,作为hook的顺序标识。
|
||||||
- 以`-`分割顺序和hook名。
|
- 以`-`分割顺序和hook名。
|
||||||
- 文件格式需要是`json`,文件扩展名同样以`json`结尾。
|
- 文件格式需要是`json`,文件扩展名同样以`json`结尾。
|
||||||
|
@ -46,6 +46,24 @@ install(FILES ${DBUS_APPLICATION_MANAGER_SERVICE_FILE}
|
|||||||
install(FILES ${CMAKE_CURRENT_LIST_DIR}/dpkg/dpkg.cfg.d/am-update-hook
|
install(FILES ${CMAKE_CURRENT_LIST_DIR}/dpkg/dpkg.cfg.d/am-update-hook
|
||||||
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/dpkg/dpkg.cfg.d)
|
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/dpkg/dpkg.cfg.d)
|
||||||
|
|
||||||
|
# configure and install dde-dock hooks
|
||||||
|
set(HOOKS_DEST_DIR ${CMAKE_INSTALL_DATADIR}/deepin/dde-application-manager/hooks.d)
|
||||||
|
configure_file(
|
||||||
|
hooks.d/1-dockEnv.json.in
|
||||||
|
hooks.d/1-dockEnv.json
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hooks.d/1-dockEnv.json
|
||||||
|
DESTINATION ${HOOKS_DEST_DIR})
|
||||||
|
|
||||||
|
install(FILES ${CMAKE_CURRENT_LIST_DIR}/hooks.d/dockEnv.sh
|
||||||
|
DESTINATION ${AM_LIBEXEC_DIR}
|
||||||
|
PERMISSIONS
|
||||||
|
OWNER_READ OWNER_EXECUTE OWNER_WRITE
|
||||||
|
GROUP_READ GROUP_EXECUTE
|
||||||
|
WORLD_READ WORLD_EXECUTE
|
||||||
|
)
|
||||||
|
|
||||||
# FIXME: move to other project
|
# FIXME: move to other project
|
||||||
set(DCONFIG_FILES
|
set(DCONFIG_FILES
|
||||||
${CMAKE_CURRENT_LIST_DIR}/dsg/configs/dde-application-manager/com.deepin.dde.launcher.json
|
${CMAKE_CURRENT_LIST_DIR}/dsg/configs/dde-application-manager/com.deepin.dde.launcher.json
|
||||||
|
4
misc/hooks.d/1-dockEnv.json.in
Normal file
4
misc/hooks.d/1-dockEnv.json.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"Exec": "@CMAKE_INSTALL_PREFIX@/@AM_LIBEXEC_DIR@/dockEnv.sh",
|
||||||
|
"Args":[]
|
||||||
|
}
|
11
misc/hooks.d/dockEnv.sh
Normal file
11
misc/hooks.d/dockEnv.sh
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# SPDX-FileCopyrightText: 2024 UnionTech Software Technology Co., Ltd.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
|
# This hook is required by dde-dock that detect identity of Application.
|
||||||
|
# May be remove on later.
|
||||||
|
|
||||||
|
export GIO_LAUNCHED_DESKTOP_FILE_PID=$$
|
||||||
|
exec "$@"
|
@ -49,12 +49,12 @@ double getScaleFactor() noexcept
|
|||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
void appendRuntimeScaleFactor(const ApplicationService &app, QVariantMap &runtimeOptions) noexcept
|
void ApplicationService::appendExtraEnvironments(QVariantMap &runtimeOptions) const noexcept
|
||||||
{
|
{
|
||||||
static QStringList scaleEnvs{"DEEPIN_WINE_SCALE=%1;", "GDK_DPI_SCALE=%1;", "QT_SCALE_FACTOR=%1;", "GDK_SCALE=%1;"};
|
|
||||||
QString oldEnv;
|
QString oldEnv;
|
||||||
|
// scale factor
|
||||||
auto factor = app.scaleFactor();
|
static QStringList scaleEnvs{"DEEPIN_WINE_SCALE=%1;", "GDK_DPI_SCALE=%1;", "QT_SCALE_FACTOR=%1;", "GDK_SCALE=%1;"};
|
||||||
|
auto factor = scaleFactor();
|
||||||
if (auto it = runtimeOptions.find("env"); it != runtimeOptions.cend()) {
|
if (auto it = runtimeOptions.find("env"); it != runtimeOptions.cend()) {
|
||||||
oldEnv = it->value<QString>();
|
oldEnv = it->value<QString>();
|
||||||
}
|
}
|
||||||
@ -63,6 +63,9 @@ void appendRuntimeScaleFactor(const ApplicationService &app, QVariantMap &runtim
|
|||||||
oldEnv.append(env.arg(factor));
|
oldEnv.append(env.arg(factor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GIO
|
||||||
|
oldEnv.append(QString{"GIO_LAUNCHED_DESKTOP_FILE=%1;"}.arg(m_desktopSource.sourcePath()));
|
||||||
|
|
||||||
runtimeOptions.insert("env", oldEnv);
|
runtimeOptions.insert("env", oldEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,8 +235,7 @@ ApplicationService::Launch(const QString &action, const QStringList &fields, con
|
|||||||
QString execStr{};
|
QString execStr{};
|
||||||
const auto &supportedActions = actions();
|
const auto &supportedActions = actions();
|
||||||
auto optionsMap = options;
|
auto optionsMap = options;
|
||||||
|
appendExtraEnvironments(optionsMap);
|
||||||
appendRuntimeScaleFactor(*this, optionsMap);
|
|
||||||
|
|
||||||
if (!realExec.isNull()) { // we want to replace exec of this applications.
|
if (!realExec.isNull()) { // we want to replace exec of this applications.
|
||||||
if (realExec.isEmpty()) {
|
if (realExec.isEmpty()) {
|
||||||
|
@ -190,6 +190,7 @@ private:
|
|||||||
static bool shouldBeShown(const std::unique_ptr<DesktopEntry> &entry) noexcept;
|
static bool shouldBeShown(const std::unique_ptr<DesktopEntry> &entry) noexcept;
|
||||||
[[nodiscard]] bool autostartCheck(const QString &filePath) const noexcept;
|
[[nodiscard]] bool autostartCheck(const QString &filePath) const noexcept;
|
||||||
void setAutostartSource(AutostartSource &&source) noexcept;
|
void setAutostartSource(AutostartSource &&source) noexcept;
|
||||||
|
void appendExtraEnvironments(QVariantMap &runtimeOptions) const noexcept;
|
||||||
[[nodiscard]] ApplicationManager1Service *parent() { return dynamic_cast<ApplicationManager1Service *>(QObject::parent()); }
|
[[nodiscard]] ApplicationManager1Service *parent() { return dynamic_cast<ApplicationManager1Service *>(QObject::parent()); }
|
||||||
[[nodiscard]] const ApplicationManager1Service *parent() const
|
[[nodiscard]] const ApplicationManager1Service *parent() const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user