#!/bin/bash # ======================================== # Deepin OS 锁屏检测测试脚本 # ======================================== echo "========================================" echo "Deepin OS Screen Lock Detection Test" echo "========================================" echo "" # 颜色定义 RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # 检测是否在 Deepin OS 上运行 echo "Step 1: Checking if running on Deepin OS..." if [ -f /etc/deepin-version ]; then DEEPIN_VERSION=$(cat /etc/deepin-version) echo -e "${GREEN}✓${NC} Deepin OS detected: $DEEPIN_VERSION" elif [ -f /etc/os-release ]; then if grep -q "Deepin" /etc/os-release; then echo -e "${GREEN}✓${NC} Deepin OS detected" else echo -e "${YELLOW}⚠${NC} Not running on Deepin OS" echo " This script is designed for Deepin OS, but will continue anyway..." fi else echo -e "${YELLOW}⚠${NC} Cannot determine OS version" fi echo "" # 检查 DDE 桌面环境 echo "Step 2: Checking DDE Desktop Environment..." if pgrep -x "dde-desktop" > /dev/null; then echo -e "${GREEN}✓${NC} DDE desktop is running" else echo -e "${RED}✗${NC} DDE desktop is not running" echo " Please make sure you are running DDE desktop environment" fi if pgrep -x "dde-lock" > /dev/null; then echo -e "${GREEN}✓${NC} dde-lock process found" else echo -e "${YELLOW}⚠${NC} dde-lock process not found (this is normal when screen is unlocked)" fi echo "" # 检查 DBus 会话 echo "Step 3: Checking DBus session..." if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then echo -e "${RED}✗${NC} DBUS_SESSION_BUS_ADDRESS not set" echo " Please run this script in a graphical session" else echo -e "${GREEN}✓${NC} DBus session is available" fi echo "" # 检查 Deepin DDE lockFront 服务 echo "Step 4: Checking Deepin DDE lockFront service..." if command -v dbus-send &> /dev/null; then if dbus-send --session --print-reply \ --dest=com.deepin.dde.lockFront \ /com/deepin/dde/lockFront \ org.freedesktop.DBus.Introspectable.Introspect &> /dev/null; then echo -e "${GREEN}✓${NC} Deepin DDE lockFront service is available" else echo -e "${RED}✗${NC} Deepin DDE lockFront service is not available" echo " The application may not be able to detect screen lock events" fi else echo -e "${YELLOW}⚠${NC} dbus-send command not found, cannot verify service" fi echo "" # 检查项目编译状态 echo "Step 5: Checking project build status..." if [ -f "build/bin/ScreenLockDemo" ]; then echo -e "${GREEN}✓${NC} Application is built: build/bin/ScreenLockDemo" else echo -e "${RED}✗${NC} Application not found. Please run ./build.sh first" echo "" exit 1 fi echo "" # 检查 Qt 库 echo "Step 6: Checking Qt libraries..." QT_PATH="$HOME/sdk/qt-5.15.2" if [ -d "$QT_PATH" ]; then echo -e "${GREEN}✓${NC} Qt5 found at: $QT_PATH" else echo -e "${YELLOW}⚠${NC} Qt5 not found at expected location: $QT_PATH" echo " Attempting to use system Qt..." fi echo "" # 提供测试说明 echo "========================================" echo "Test Instructions" echo "========================================" echo "" echo "The application will now start. Please follow these steps:" echo "" echo "1. Verify the application window appears with animation" echo "2. Check console output for: ${GREEN}'Deepin DDE connected: true'${NC}" echo "3. Lock your screen using one of these methods:" echo " - Press ${BLUE}Super + L${NC}" echo " - Press ${BLUE}Ctrl + Alt + L${NC}" echo " - Run command: ${BLUE}dde-lock${NC}" echo "4. Observe that the animation stops" echo "5. Unlock your screen" echo "6. Verify that the animation resumes" echo "" echo "Expected console output when locking:" echo " ${GREEN}Login Manager Lock signal received${NC}" echo " ${GREEN}Screen lock state changed: LOCKED${NC}" echo "" echo "Expected console output when unlocking:" echo " ${GREEN}Login Manager Unlock signal received${NC}" echo " ${GREEN}Screen lock state changed: UNLOCKED${NC}" echo "" echo "========================================" echo "" # 询问是否继续 read -p "Press ENTER to start the application, or Ctrl+C to cancel..." echo "" # 启动应用 echo "Starting application with debug output..." echo "========================================" echo "" # 设置环境变量并运行 if [ -d "$QT_PATH" ]; then export LD_LIBRARY_PATH="$QT_PATH/lib:$LD_LIBRARY_PATH" fi # 运行应用并保存日志 ./build/bin/ScreenLockDemo 2>&1 | tee deepin_test_$(date +%Y%m%d_%H%M%S).log echo "" echo "========================================" echo "Test completed. Log file saved." echo "========================================"