#!/bin/bash # macOS Run Script for ScreenLockDetector # This script runs the application on macOS set -e # Exit on error echo "==========================================" echo "Running ScreenLockDetector on macOS" echo "==========================================" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Check if we're on macOS if [[ "$OSTYPE" != "darwin"* ]]; then echo -e "${RED}Error: This script is for macOS only${NC}" exit 1 fi # Set up Vulkan SDK environment for MoltenVK VULKAN_SDK="$HOME/VulkanSDK/1.4.328.1/macOS" if [ -d "$VULKAN_SDK" ]; then echo -e "${GREEN}Found Vulkan SDK at: $VULKAN_SDK${NC}" export VULKAN_SDK export DYLD_LIBRARY_PATH="$VULKAN_SDK/lib:$DYLD_LIBRARY_PATH" export VK_ICD_FILENAMES="$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json" export VK_ADD_LAYER_PATH="$VULKAN_SDK/share/vulkan/explicit_layer.d" else echo -e "${YELLOW}Warning: Vulkan SDK not found at $VULKAN_SDK${NC}" echo "Vulkan rendering may not work. Install from: https://vulkan.lunarg.com/sdk/home" echo "" fi # Check if executable exists EXECUTABLE="build/bin/ScreenLockDetector" if [ ! -f "$EXECUTABLE" ]; then echo -e "${RED}Error: Executable not found at $EXECUTABLE${NC}" echo "" echo "Please build the project first:" echo " ./build_mac.sh" exit 1 fi # Function to find Qt installation find_qt() { # Try to find Qt in common locations QT_PATHS=( "/opt/local" # MacPorts "/usr/local/opt/qt@5" # Homebrew (Intel) "/opt/homebrew/opt/qt@5" # Homebrew (Apple Silicon) "$HOME/Qt/5.15.2/clang_64" # Official Qt installer "$HOME/sdk/qt-5.15.2" # Custom installation ) for path in "${QT_PATHS[@]}"; do if [ -d "$path" ]; then # Check if Qt cmake files exist if [ -f "$path/lib/cmake/Qt5/Qt5Config.cmake" ]; then echo "$path" return 0 fi fi done return 1 } # Find Qt installation and set up library path QT_PATH=$(find_qt) if [ -n "$QT_PATH" ]; then echo -e "${GREEN}Found Qt at: $QT_PATH${NC}" export DYLD_LIBRARY_PATH="$QT_PATH/lib:$DYLD_LIBRARY_PATH" export DYLD_FRAMEWORK_PATH="$QT_PATH/lib:$DYLD_FRAMEWORK_PATH" else echo -e "${YELLOW}Warning: Qt not found in common locations${NC}" echo "If the application fails to run, please set DYLD_LIBRARY_PATH manually:" echo " export DYLD_LIBRARY_PATH=/path/to/qt/lib:\$DYLD_LIBRARY_PATH" echo "" fi # Run the application echo "" echo "Starting ScreenLockDetector..." echo "==========================================" echo "" ./"$EXECUTABLE" echo "" echo "Application exited."