check-display.sh 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #!/bin/bash
  2. # Check display/framebuffer status before starting kiosk mode
  3. echo "🔍 Display & Framebuffer Status Check"
  4. echo "======================================"
  5. echo ""
  6. # Check if running as root (should NOT be)
  7. if [ "$EUID" -eq 0 ]; then
  8. echo "⚠️ WARNING: You are running this as root/sudo"
  9. echo " This is for checking only. When you run the app, do NOT use sudo!"
  10. echo " EGL/GPU access fails when running as root."
  11. echo ""
  12. fi
  13. # Check for running display servers
  14. echo "🖥️ Display Servers:"
  15. if pgrep -x "Xorg" > /dev/null; then
  16. echo " ⚠️ X11 (Xorg) is running - PID: $(pgrep -x Xorg)"
  17. echo " This will conflict with EGLFS!"
  18. echo " 💡 Stop with: sudo systemctl stop lightdm"
  19. elif pgrep -x "weston" > /dev/null; then
  20. echo " ⚠️ Wayland (Weston) is running - PID: $(pgrep -x weston)"
  21. echo " This will conflict with EGLFS!"
  22. echo " 💡 Stop with: pkill weston"
  23. elif pgrep "lxsession" > /dev/null; then
  24. echo " ⚠️ LXDE desktop is running"
  25. echo " This will conflict with EGLFS!"
  26. echo " 💡 Stop with: sudo systemctl stop lightdm"
  27. else
  28. echo " ✅ No display server detected (good for EGLFS)"
  29. fi
  30. echo ""
  31. # Check framebuffer
  32. echo "📺 Framebuffer Device:"
  33. if [ -c "/dev/fb0" ]; then
  34. echo " ✅ /dev/fb0 exists"
  35. # Check permissions
  36. if [ -r "/dev/fb0" ] && [ -w "/dev/fb0" ]; then
  37. echo " ✅ Readable and writable by current user"
  38. else
  39. echo " ⚠️ Permission issue!"
  40. ls -l /dev/fb0
  41. echo " Current user: $(whoami)"
  42. echo " Groups: $(groups)"
  43. echo " 💡 Fix: sudo usermod -a -G video $(whoami)"
  44. echo " Then logout and login again"
  45. fi
  46. # Check if framebuffer is in use
  47. if lsof /dev/fb0 2>/dev/null | grep -v "COMMAND" > /dev/null; then
  48. echo " ⚠️ Framebuffer is in use by:"
  49. lsof /dev/fb0 2>/dev/null || true
  50. else
  51. echo " ✅ Framebuffer is available (not in use)"
  52. fi
  53. else
  54. echo " ❌ /dev/fb0 not found!"
  55. fi
  56. echo ""
  57. # Check DRM devices
  58. echo "🎨 DRM/GPU Devices:"
  59. if [ -d "/dev/dri" ]; then
  60. echo " ✅ /dev/dri exists"
  61. ls -la /dev/dri/
  62. # Check permissions on DRM devices
  63. for device in /dev/dri/*; do
  64. if [ -r "$device" ] && [ -w "$device" ]; then
  65. echo " ✅ $device is accessible"
  66. else
  67. echo " ⚠️ $device has permission issues"
  68. echo " 💡 Fix: sudo usermod -a -G video,render $(whoami)"
  69. fi
  70. done
  71. else
  72. echo " ℹ️ /dev/dri not found (may use legacy fb0 only)"
  73. fi
  74. echo ""
  75. # Check user groups
  76. echo "👤 User Groups:"
  77. CURRENT_USER=$(whoami)
  78. GROUPS=$(groups)
  79. echo " User: $CURRENT_USER"
  80. echo " Groups: $GROUPS"
  81. if echo "$GROUPS" | grep -q "video"; then
  82. echo " ✅ In 'video' group"
  83. else
  84. echo " ⚠️ NOT in 'video' group"
  85. echo " 💡 Fix: sudo usermod -a -G video $CURRENT_USER"
  86. fi
  87. if echo "$GROUPS" | grep -q "render"; then
  88. echo " ✅ In 'render' group (good for DRM)"
  89. else
  90. echo " ℹ️ Not in 'render' group (may be needed for some GPUs)"
  91. echo " 💡 Add with: sudo usermod -a -G render $CURRENT_USER"
  92. fi
  93. echo ""
  94. # Check console
  95. echo "🖥️ Console Status:"
  96. if [ -n "$DISPLAY" ]; then
  97. echo " ⚠️ DISPLAY=$DISPLAY is set"
  98. echo " This suggests X11 is running"
  99. echo " 💡 For EGLFS, unset with: unset DISPLAY"
  100. else
  101. echo " ✅ DISPLAY not set (good for EGLFS)"
  102. fi
  103. if [ "$(tty)" = "not a tty" ]; then
  104. echo " ⚠️ Not running from a TTY"
  105. else
  106. echo " ✅ Running from TTY: $(tty)"
  107. fi
  108. echo ""
  109. # Recommendations
  110. echo "💡 Recommendations:"
  111. echo ""
  112. ISSUES=0
  113. if pgrep -x "Xorg\|weston\|lxsession" > /dev/null; then
  114. echo "1. ⚠️ CRITICAL: Stop the desktop environment"
  115. echo " sudo systemctl stop lightdm"
  116. echo " # OR for other DMs:"
  117. echo " sudo systemctl stop gdm"
  118. echo " sudo systemctl stop sddm"
  119. echo ""
  120. ISSUES=$((ISSUES + 1))
  121. fi
  122. if ! echo "$(groups)" | grep -q "video"; then
  123. echo "2. ⚠️ Add user to video group:"
  124. echo " sudo usermod -a -G video $(whoami)"
  125. echo " Then logout and login again"
  126. echo ""
  127. ISSUES=$((ISSUES + 1))
  128. fi
  129. if [ ! -r "/dev/fb0" ] || [ ! -w "/dev/fb0" ]; then
  130. echo "3. ⚠️ Fix framebuffer permissions"
  131. echo " (Should be fixed by adding to video group)"
  132. echo ""
  133. ISSUES=$((ISSUES + 1))
  134. fi
  135. if [ $ISSUES -eq 0 ]; then
  136. echo "✅ All checks passed! Ready to run in EGLFS mode"
  137. echo ""
  138. echo "Start with:"
  139. echo " ./run.sh --kiosk"
  140. else
  141. echo "❌ Found $ISSUES issue(s) that need to be fixed"
  142. echo ""
  143. echo "After fixing, reboot or re-login for group changes to take effect"
  144. fi
  145. echo ""