ScreenLockDetector/debug_deepin_dbus.sh

170 lines
5.1 KiB
Bash
Executable File

#!/bin/bash
# ========================================
# Deepin DBus 信号调试脚本
# 用于监听和分析 Deepin 锁屏相关的 DBus 信号
# ========================================
echo "========================================"
echo "Deepin DBus Signal Debug Tool"
echo "========================================"
echo ""
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# 检查必要的工具
echo "Checking required tools..."
if ! command -v dbus-monitor &> /dev/null; then
echo -e "${RED}${NC} dbus-monitor not found. Please install: sudo apt install dbus"
exit 1
fi
if ! command -v dbus-send &> /dev/null; then
echo -e "${RED}${NC} dbus-send not found. Please install: sudo apt install dbus"
exit 1
fi
echo -e "${GREEN}${NC} All required tools available"
echo ""
# 列出可能的 Deepin 相关服务
echo "========================================"
echo "Step 1: Searching for Deepin DBus services"
echo "========================================"
echo ""
echo "Session Bus Services:"
dbus-send --session --print-reply --dest=org.freedesktop.DBus \
/org/freedesktop/DBus org.freedesktop.DBus.ListNames 2>/dev/null | \
grep -i "deepin" || echo "No Deepin services found on session bus"
echo ""
echo "System Bus Services:"
dbus-send --system --print-reply --dest=org.freedesktop.DBus \
/org/freedesktop/DBus org.freedesktop.DBus.ListNames 2>/dev/null | \
grep -i "deepin" || echo "No Deepin services found on system bus"
echo ""
echo "========================================"
echo "Step 2: Checking common Deepin lock services"
echo "========================================"
echo ""
# 常见的 Deepin 锁屏服务列表
SERVICES=(
"com.deepin.dde.lockFront"
"com.deepin.dde.LockFront"
"com.deepin.ScreenSaver"
"com.deepin.SessionManager"
"com.deepin.daemon.LockService"
"org.deepin.dde.lockFront"
"org.deepin.dde.LockService"
)
FOUND_SERVICES=()
for service in "${SERVICES[@]}"; do
echo -n "Checking $service ... "
if dbus-send --session --print-reply --dest="$service" / org.freedesktop.DBus.Introspectable.Introspect &>/dev/null; then
echo -e "${GREEN}✓ Found (Session)${NC}"
FOUND_SERVICES+=("$service:session")
elif dbus-send --system --print-reply --dest="$service" / org.freedesktop.DBus.Introspectable.Introspect &>/dev/null; then
echo -e "${GREEN}✓ Found (System)${NC}"
FOUND_SERVICES+=("$service:system")
else
echo -e "${RED}✗ Not found${NC}"
fi
done
echo ""
if [ ${#FOUND_SERVICES[@]} -eq 0 ]; then
echo -e "${YELLOW}⚠ No Deepin lock services found${NC}"
echo ""
echo "Possible reasons:"
echo " 1. Not running on Deepin OS"
echo " 2. DDE lock service not started"
echo " 3. Service names have changed in your Deepin version"
echo ""
echo "Let's monitor ALL session bus signals to find the right one..."
echo ""
fi
# 显示找到的服务详情
if [ ${#FOUND_SERVICES[@]} -gt 0 ]; then
echo "========================================"
echo "Step 3: Service Details"
echo "========================================"
echo ""
for entry in "${FOUND_SERVICES[@]}"; do
service="${entry%:*}"
bus="${entry#*:}"
echo -e "${CYAN}=== $service ($bus bus) ===${NC}"
if [ "$bus" = "session" ]; then
BUS_OPTION="--session"
else
BUS_OPTION="--system"
fi
# 尝试获取接口详情
dbus-send $BUS_OPTION --print-reply --dest="$service" / \
org.freedesktop.DBus.Introspectable.Introspect 2>/dev/null | \
grep -E "interface name|signal name|method name" | head -20
echo ""
done
fi
echo "========================================"
echo "Step 4: Monitor DBus Signals"
echo "========================================"
echo ""
echo "This will monitor DBus signals in REAL-TIME."
echo "Please follow these steps:"
echo ""
echo " 1. Keep this terminal visible"
echo " 2. Lock your screen using:"
echo " - Press ${BLUE}Super + L${NC}"
echo " - Or run: ${BLUE}dde-lock${NC}"
echo " 3. Observe the signals that appear"
echo " 4. Unlock your screen"
echo " 5. Press ${RED}Ctrl+C${NC} to stop monitoring"
echo ""
echo "We'll look for signals containing: lock, Lock, screen, Screen"
echo ""
read -p "Press ENTER to start monitoring, or Ctrl+C to cancel..."
echo ""
echo -e "${GREEN}Monitoring started...${NC}"
echo "========================================"
echo ""
# 创建临时文件记录所有信号
TEMP_LOG="/tmp/deepin_dbus_signals_$(date +%s).log"
# 启动监听(过滤可能相关的信号)
dbus-monitor --session "type='signal'" 2>&1 | \
grep --line-buffered -iE "signal|lock|Lock|screen|Screen|Active|session|Session" | \
tee "$TEMP_LOG" | \
while IFS= read -r line; do
if echo "$line" | grep -q "signal"; then
echo -e "${YELLOW}$line${NC}"
elif echo "$line" | grep -iq "lock"; then
echo -e "${GREEN}$line${NC}"
else
echo "$line"
fi
done
echo ""
echo "Log saved to: $TEMP_LOG"