#!/bin/bash # 重新加载 D-Bus 会话配置 # 注意:这可能会影响当前会话中的其他应用程序 echo "Reloading D-Bus session configuration..." echo "Warning: This may affect other applications in your session." echo "" # 查找会话 D-Bus 守护进程 SESSION_DBUS_PID=$(ps aux | grep -E "dbus-daemon.*session" | grep -v grep | awk '{print $2}' | head -1) if [ -z "$SESSION_DBUS_PID" ]; then echo "Error: Could not find session D-Bus daemon" exit 1 fi echo "Found session D-Bus daemon (PID: $SESSION_DBUS_PID)" echo "" echo "To apply the new configuration, you have two options:" echo "" echo "Option 1 (Recommended): Log out and log back in" echo " This is the safest way to reload D-Bus configuration" echo "" echo "Option 2: Restart D-Bus session daemon" echo " This will restart automatically, but may briefly interrupt D-Bus services" echo " Run: killall -HUP dbus-daemon" echo "" read -p "Do you want to restart D-Bus now? (y/N): " -n 1 -r echo "" if [[ $REPLY =~ ^[Yy]$ ]]; then echo "Restarting D-Bus session daemon..." killall -HUP dbus-daemon sleep 1 echo "✓ D-Bus session daemon restarted" echo "" echo "The configuration should now be active. Try running your daemon again." else echo "Skipped. Please log out and log back in to apply the configuration." fi