#!/bin/bash # Test Display Manager functionality SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" EVENT_FILE="$PROJECT_ROOT/src/current_event.json" echo "๐Ÿงช Testing Display Manager" echo "=========================" echo "" # Function to create test event create_test_event() { local event_type=$1 echo "๐Ÿ“ Creating test event: $event_type" case $event_type in "presentation") cat > "$EVENT_FILE" < "$EVENT_FILE" < "$EVENT_FILE" < /dev/null; then echo "โœ… Display Manager is running" echo " PID: $(pgrep -f display_manager.py)" return 0 else echo "โŒ Display Manager is NOT running" return 1 fi } # Function to check for display processes check_display_processes() { echo "๐Ÿ” Active display processes:" # Check for LibreOffice if pgrep -f "libreoffice.*impress" > /dev/null; then echo " ๐Ÿ“Š LibreOffice Impress: PID $(pgrep -f 'libreoffice.*impress')" fi # Check for browsers if pgrep -f "chromium.*kiosk" > /dev/null; then echo " ๐ŸŒ Chromium (kiosk): PID $(pgrep -f 'chromium.*kiosk')" fi # Check for video players if pgrep -f "vlc" > /dev/null; then echo " ๐ŸŽฌ VLC: PID $(pgrep -f 'vlc')" fi if pgrep -f "mpv" > /dev/null; then echo " ๐ŸŽฌ MPV: PID $(pgrep -f 'mpv')" fi # Check for PDF viewers if pgrep -f "evince" > /dev/null; then echo " ๐Ÿ“„ Evince: PID $(pgrep -f 'evince')" fi # Check for Impressive if pgrep -f "impressive" > /dev/null; then echo " ๐Ÿ“Š Impressive: PID $(pgrep -f 'impressive')" fi echo "" } # Main menu echo "Display Manager Test Menu" echo "=========================" echo "" echo "What would you like to test?" echo "1) Check Display Manager status" echo "2) Create PRESENTATION test event" echo "3) Create WEBPAGE test event" echo "4) Create VIDEO test event" echo "5) Remove event (no display)" echo "6) Check active display processes" echo "7) View current event file" echo "8) Interactive test (cycle through events)" echo "9) Exit" echo "" read -p "Enter choice [1-9]: " choice case $choice in 1) check_display_manager check_display_processes ;; 2) create_test_event "presentation" echo "โฑ๏ธ Display Manager will pick this up within 5 seconds..." ;; 3) create_test_event "webpage" echo "โฑ๏ธ Display Manager will pick this up within 5 seconds..." ;; 4) create_test_event "video" echo "โฑ๏ธ Display Manager will pick this up within 5 seconds..." ;; 5) create_test_event "none" echo "โฑ๏ธ Display Manager will stop display within 5 seconds..." ;; 6) check_display_manager check_display_processes ;; 7) if [ -f "$EVENT_FILE" ]; then echo "๐Ÿ“„ Current event file:" cat "$EVENT_FILE" else echo "โŒ No event file found" fi ;; 8) echo "๐Ÿ”„ Interactive test - cycling through event types" echo " Display Manager must be running for this test!" echo "" check_display_manager || exit 1 echo "1๏ธโƒฃ Testing PRESENTATION (10 seconds)..." create_test_event "presentation" sleep 10 echo "2๏ธโƒฃ Testing WEBPAGE (10 seconds)..." create_test_event "webpage" sleep 10 echo "3๏ธโƒฃ Testing NO EVENT (5 seconds)..." create_test_event "none" sleep 5 echo "4๏ธโƒฃ Back to PRESENTATION..." create_test_event "presentation" echo "โœ… Interactive test complete!" ;; 9) echo "๐Ÿ‘‹ Goodbye!" exit 0 ;; *) echo "โŒ Invalid choice" exit 1 ;; esac