"""Launch file for Night Mode controller node."""

from launch import LaunchDescription
from launch_ros.actions import Node
from launch.substitutions import LaunchConfiguration
from launch.actions import DeclareLaunchArgument
from ament_index_python.packages import get_package_share_directory
from pathlib import Path


def generate_launch_description():
    """Generate launch description."""
    package_dir = get_package_share_directory("saltybot_night_mode")
    config_file = str(Path(package_dir) / "config" / "night_mode_config.yaml")

    # Launch arguments
    config_arg = DeclareLaunchArgument(
        "config_file",
        default_value=config_file,
        description="Path to night mode configuration file",
    )

    # Night Mode node
    night_mode_node = Node(
        package="saltybot_night_mode",
        executable="night_mode_node",
        name="night_mode_controller",
        parameters=[
            {
                "config_file": LaunchConfiguration("config_file"),
            }
        ],
        output="screen",
    )

    return LaunchDescription([config_arg, night_mode_node])
