164 lines
4.7 KiB
Bash
Executable File
164 lines
4.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# ========================================
|
|
# 快速验证锁屏信号修复脚本
|
|
# ========================================
|
|
|
|
echo "========================================"
|
|
echo "Lock Signal Fix Verification Script"
|
|
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 "Step 1: Checking build..."
|
|
echo "--------------------------------------"
|
|
if [ ! -f "build/bin/ScreenLockDemo" ]; then
|
|
echo -e "${RED}✗${NC} Executable not found. Running build..."
|
|
./build.sh
|
|
if [ $? -ne 0 ]; then
|
|
echo -e "${RED}✗${NC} Build failed!"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo -e "${GREEN}✓${NC} Executable exists"
|
|
fi
|
|
echo ""
|
|
|
|
# 检查环境信息
|
|
echo "Step 2: Environment Information"
|
|
echo "--------------------------------------"
|
|
echo "Desktop Environment:"
|
|
echo " XDG_CURRENT_DESKTOP: ${XDG_CURRENT_DESKTOP:-<not set>}"
|
|
echo " DESKTOP_SESSION: ${DESKTOP_SESSION:-<not set>}"
|
|
echo ""
|
|
echo "Session Information:"
|
|
echo " XDG_SESSION_ID: ${XDG_SESSION_ID:-<not set>}"
|
|
echo " XDG_SESSION_TYPE: ${XDG_SESSION_TYPE:-<not set>}"
|
|
echo ""
|
|
|
|
# 计算会话路径
|
|
if [ -n "$XDG_SESSION_ID" ]; then
|
|
SESSION_PATH="/org/freedesktop/login1/session/$XDG_SESSION_ID"
|
|
echo "Expected session path: $SESSION_PATH"
|
|
echo ""
|
|
fi
|
|
|
|
# 检查可用的服务
|
|
echo "Step 3: Available DBus Services"
|
|
echo "--------------------------------------"
|
|
|
|
echo "Checking for lock services:"
|
|
|
|
# GNOME ScreenSaver
|
|
echo -n " org.gnome.ScreenSaver (session): "
|
|
if dbus-send --session --print-reply --dest=org.gnome.ScreenSaver \
|
|
/org/gnome/ScreenSaver \
|
|
org.freedesktop.DBus.Introspectable.Introspect &>/dev/null; then
|
|
echo -e "${GREEN}✓ Available${NC}"
|
|
HAS_SERVICE=1
|
|
else
|
|
echo -e "${RED}✗ Not available${NC}"
|
|
fi
|
|
|
|
# systemd-logind
|
|
echo -n " org.freedesktop.login1 (system): "
|
|
if dbus-send --system --print-reply --dest=org.freedesktop.login1 \
|
|
/org/freedesktop/login1 \
|
|
org.freedesktop.DBus.Introspectable.Introspect &>/dev/null; then
|
|
echo -e "${GREEN}✓ Available${NC}"
|
|
HAS_SERVICE=1
|
|
else
|
|
echo -e "${RED}✗ Not available${NC}"
|
|
fi
|
|
|
|
# Deepin services
|
|
DEEPIN_SERVICES=(
|
|
"com.deepin.dde.lockFront"
|
|
"com.deepin.ScreenSaver"
|
|
"org.deepin.dde.lockFront"
|
|
)
|
|
|
|
for service in "${DEEPIN_SERVICES[@]}"; do
|
|
echo -n " $service (session): "
|
|
if dbus-send --session --print-reply --dest="$service" / \
|
|
org.freedesktop.DBus.Introspectable.Introspect &>/dev/null; then
|
|
echo -e "${GREEN}✓ Available${NC}"
|
|
HAS_SERVICE=1
|
|
else
|
|
echo -e "${RED}✗ Not available${NC}"
|
|
fi
|
|
done
|
|
|
|
echo ""
|
|
|
|
if [ -z "$HAS_SERVICE" ]; then
|
|
echo -e "${YELLOW}⚠ Warning: No lock services detected${NC}"
|
|
echo "This might be expected if running in a minimal environment"
|
|
echo ""
|
|
fi
|
|
|
|
# 运行程序
|
|
echo "Step 4: Running Application"
|
|
echo "--------------------------------------"
|
|
echo ""
|
|
echo -e "${CYAN}The application will now start.${NC}"
|
|
echo -e "${CYAN}Please check the output for connection status.${NC}"
|
|
echo ""
|
|
echo "Look for these indicators:"
|
|
echo " ${GREEN}✓${NC} 'ScreenLockDetector initialized successfully'"
|
|
echo " ${GREEN}✓${NC} At least one 'connected: true'"
|
|
echo " ${GREEN}✓${NC} Valid session path (not 'auto')"
|
|
echo ""
|
|
echo "Then test by locking your screen:"
|
|
echo " - Press ${BLUE}Super+L${NC} or ${BLUE}Ctrl+Alt+L${NC}"
|
|
echo " - Look for ${GREEN}'LOCK SIGNAL RECEIVED'${NC} in the output"
|
|
echo " - Unlock and look for ${GREEN}'UNLOCK SIGNAL RECEIVED'${NC}"
|
|
echo ""
|
|
echo "Press Ctrl+C to stop the application when done."
|
|
echo ""
|
|
|
|
read -p "Press ENTER to start the application..."
|
|
|
|
echo ""
|
|
echo "========================================"
|
|
echo "Application Output:"
|
|
echo "========================================"
|
|
echo ""
|
|
|
|
cd build/bin
|
|
./ScreenLockDemo
|
|
|
|
echo ""
|
|
echo "========================================"
|
|
echo "Application stopped"
|
|
echo "========================================"
|
|
echo ""
|
|
|
|
# 提供进一步调试建议
|
|
echo "If signals were NOT received:"
|
|
echo "--------------------------------------"
|
|
echo "1. Run the detailed test script:"
|
|
echo " ${CYAN}./test_lock_signals.sh${NC}"
|
|
echo ""
|
|
echo "2. Check what signals your system actually sends:"
|
|
echo " ${CYAN}dbus-monitor --system \"type='signal',interface='org.freedesktop.login1.Session'\"${NC}"
|
|
echo " Then lock your screen in another terminal"
|
|
echo ""
|
|
echo "3. For Deepin systems, run:"
|
|
echo " ${CYAN}./debug_deepin_dbus.sh${NC}"
|
|
echo ""
|
|
echo "4. Check session status:"
|
|
echo " ${CYAN}loginctl show-session \$XDG_SESSION_ID${NC}"
|
|
echo ""
|
|
echo "5. Review the detailed fix guide:"
|
|
echo " ${CYAN}cat LOCK_SIGNAL_FIX.md${NC}"
|
|
echo ""
|