Skip to content

feat: migrate camera shortcut and helper scripts - #143

Open
yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:feat/migrate-camera-shortcut-scripts
Open

feat: migrate camera shortcut and helper scripts#143
yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:feat/migrate-camera-shortcut-scripts

Conversation

@yixinshark

@yixinshark yixinshark commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add the missing XF86WebCam shortcut and preserve the legacy camera toggle behavior
  • install camera and grand-search helper scripts under a dde-services-owned path
  • keep the default-terminal shortcut on dde-daemon's independently installed binary

Test plan

  • sh -n on both helper scripts
  • validate the webcam DConfig JSON with jq
  • run shortcut-qkeysequenceconverter
  • verify both installed helper scripts have mode 0755

Summary by Sourcery

Migrate camera and grand search shortcut handling to dde-services while adding support for the XF86WebCam key.

New Features:

  • Introduce a webcam shortcut configuration wired to the XF86WebCam key and corresponding camera-switch helper script.

Enhancements:

  • Relocate grand search shortcut execution to a new toggle-grand-search helper under the dde-services keybinding libexec path.
  • Install camera and grand search helper scripts under a dde-services-owned libexec keybinding directory to align with service ownership.

Tests:

  • Extend shortcut key sequence converter tests to cover the WebCam/XF86WebCam mapping.

Add the missing XF86WebCam shortcut and preserve the legacy camera toggle behavior. Move the camera and grand-search helpers under dde-services-owned paths so removing the legacy dde-daemon keybinding module does not break these shortcut actions. Keep using dde-daemon's independently installed default-terminal binary to preserve its complete launch behavior. Update registrations and the multimedia key conversion test.

补充缺失的 XF86WebCam 快捷键并保持旧方案的相机开关行为。将相机和全局搜索辅助脚本迁移到 dde-services 自有路径,避免删除 dde-daemon 旧快捷键模块后相关动作失效。默认终端继续使用 dde-daemon 独立安装的二进制,以保留完整启动行为,同时更新注册配置及多媒体按键转换测试。

Log: feat: migrate camera shortcut and helper scripts
Change-Id: I27802397bd46699778372d6d99c09231dcd3b55c

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sorry @yixinshark, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: yixinshark

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Migrates shortcut helper scripts to a dde-services-owned libexec path, wires the grand-search toggle to the new script, and adds full support (config + tests + script) for the XF86WebCam camera shortcut while keeping the default-terminal shortcut on the existing dde-daemon binary.

Sequence diagram for XF86WebCam camera shortcut execution

sequenceDiagram
    actor User
    participant ShortcutDaemon
    participant ServiceActionExecutor
    participant ActionExecutor
    participant CameraSwitchScript

    User->>ShortcutDaemon: XF86WebCam keypress
    ShortcutDaemon->>ServiceActionExecutor: execute(actionId, context)
    alt [webcam shortcut]
        ServiceActionExecutor->>ActionExecutor: executeCommand("/usr/libexec/dde-services/keybinding/camera-switch")
        ActionExecutor->>CameraSwitchScript: start
    end
Loading

Sequence diagram for grand-search toggle shortcut execution

sequenceDiagram
    actor User
    participant ShortcutDaemon
    participant ServiceActionExecutor
    participant ActionExecutor
    participant ToggleGrandSearchScript

    User->>ShortcutDaemon: grand-search shortcut
    ShortcutDaemon->>ServiceActionExecutor: execute(actionId, context)
    alt [ToggleGrandSearch]
        ServiceActionExecutor->>ActionExecutor: executeCommand("/usr/libexec/dde-services/keybinding/toggle-grand-search")
        ActionExecutor->>ToggleGrandSearchScript: start
    end
Loading

Flow diagram for migrated shortcut helper script locations

flowchart TD
    ShortcutPlugin["plugin-qt shortcut module"]
    DdeServicesLibexec["/usr/libexec/dde-services/keybinding"]
    DdeDaemonLibexec["/usr/libexec/dde-daemon/keybinding"]
    CameraSwitch["camera-switch script"]
    ToggleGrandSearch["toggle-grand-search script"]
    DefaultTerminal["default-terminal binary"]

    ShortcutPlugin --> DdeServicesLibexec
    DdeServicesLibexec --> CameraSwitch
    DdeServicesLibexec --> ToggleGrandSearch

    ShortcutPlugin --> DdeDaemonLibexec
    DdeDaemonLibexec --> DefaultTerminal
Loading

File-Level Changes

Change Details Files
Install helper scripts under a dde-services-owned libexec path and point the grand-search shortcut executor to the new location.
  • Add CMake install rule to deploy camera-switch and toggle-grand-search helper scripts as PROGRAMS into libexec/dde-services/keybinding.
  • Update ServiceActionExecutor to invoke the new toggle-grand-search helper script path under dde-services instead of the previous dde-daemon shortcut script.
src/plugin-qt/shortcut/CMakeLists.txt
src/plugin-qt/shortcut/src/core/serviceactionexecutor.cpp
Add and integrate a dedicated webcam shortcut using the XF86WebCam keysym, including configuration and tests.
  • Extend the key sequence converter test data to cover the WebCam symbol mapped to XF86WebCam.
  • Register the webcam shortcut in the main keybinding configuration list so it can be recognized and bound.
  • Introduce a DConfig JSON shortcut definition for the webcam action under the dedicated webcam shortcut config directory.
  • Add a camera-switch helper script that preserves legacy camera toggle behavior and is installed for use by the shortcut system.
src/plugin-qt/shortcut/tests/tst_qkeysequenceconverter.cpp
src/plugin-qt/shortcut/configs/org.deepin.dde.keybinding.ini
src/plugin-qt/shortcut/configs/org.deepin.dde.keybinding.shortcut.webcam/org.deepin.shortcut.json
src/plugin-qt/shortcut/scripts/camera-switch
Provide a dedicated helper script for toggling grand search under the new dde-services path.
  • Add a toggle-grand-search helper script that implements the grand-search toggle behavior and is installed into the dde-services keybinding libexec directory.
  • Keep the existing default-terminal shortcut behavior unchanged by not altering its binary path.
src/plugin-qt/shortcut/scripts/toggle-grand-search

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:100分

■ 【总体评价】

代码实现了相机切换和全局搜索快捷键脚本的添加及路径迁移,逻辑严谨且无安全风险
语法逻辑完全正确,代码质量优秀,性能良好,不存在安全漏洞,得满分

■ 【详细分析】

  • 1.语法逻辑完全正确✓

camera-switch脚本通过id -u获取用户ID并精准过滤进程,逻辑严密;toggle-grand-search脚本准确判断DBus服务注册与可见状态并取反,C++与测试代码修改无误
建议:无需修改

  • 2.代码质量优秀✓

脚本均使用绝对路径调用系统命令,有效避免PATH劫持风险;使用exec替换当前进程减少僵尸进程产生;包含规范的SPDX版权头;变量命名清晰合理
建议:无需修改

  • 3.代码性能良好✓

toggle-grand-search使用两次DBus调用完成状态查询与切换,属于标准IPC开销;camera-switch的进程检测与启动开销极低,无性能瓶颈
建议:无需修改

  • 4.代码安全存在0个安全漏洞✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
脚本中所有变量均使用双引号包裹,有效防止了词分割和通配符扩展;外部输入仅限于固定的DBus返回值,且通过grep -q过滤为布尔值后传入boolean参数,不存在命令注入或DBus参数注入风险

  • 建议:保持当前安全的编码习惯

■ 【改进建议代码示例】

--- a/src/plugin-qt/shortcut/scripts/toggle-grand-search
+++ b/src/plugin-qt/shortcut/scripts/toggle-grand-search
@@ -1,5 +1,6 @@
 #!/bin/sh
 # SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
 # SPDX-License-Identifier: LGPL-3.0-or-later
+set -e
 
 service=com.deepin.dde.GrandSearch
 object_path=/com/deepin/dde/GrandSearch

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.

2 participants