Skip to content

agnath18K/dragon_center_linux

Repository files navigation

MSI Dragon Center For Linux

A modern Flutter application for controlling MSI laptop features with a beautiful, intuitive interface.

Flutter Dart License


📑 Table of Contents

🌟 Features

🎮 Fan Control

  • Customizable fan speed profiles
  • Auto and Advanced speed modes
  • CPU generation-specific optimizations
  • Real-time fan speed monitoring
  • Temperature-based fan curve control
  • Multiple fan zones support (CPU, GPU)

⚙️ System Configuration

  • Universal and Custom profile support
  • Persistent configuration storage
  • Profile switching capabilities

🎨 Modern UI/UX

  • Responsive design
  • Intuitive controls
  • Real-time monitoring dashboard

🛠️ Technical Architecture

Core Components

graph TD
    subgraph Application Layer
        A[Dragon Center App]
        C[Config Manager]
        D[Fan Control]
        B[Setup Service]
    end

    subgraph Hardware Layer
        H[EC Helper]
        I[System Integration]
        J[Fan Profiles]
        K[Temperature Monitoring]
        L[Speed Control]
    end

    subgraph Storage Layer
        F[Shared Preferences]
        G[Configuration Files]
        M[Profile Storage]
    end

    A --> B
    A --> C
    A --> D
    
    B --> F
    C --> G
    D --> H
    
    D --> J
    D --> K
    D --> L
    
    C --> M
    
    class A,B,C,D app;
    class H,I,J,K,L hw;
    class F,G,M storage;
Loading

EC Communication Architecture

graph LR
    subgraph Application
        A[Fan Control Service]
        B[Temperature Monitor]
        C[Battery Service]
    end

    subgraph EC Interface
        D[EC Helper]
        E[Register Manager]
        F[Error Handler]
    end

    subgraph Hardware Registers
        G[Fan Control Registers]
        H[Temperature Registers]
        I[Battery Control Registers]
    end

    A --> D
    B --> D
    C --> D

    D --> E
    E --> F

    E --> G
    E --> H
    E --> I
    
    class A,B,C app;
    class D,E,F interface;
    class G,H,I hw;
Loading

Fan Control System

sequenceDiagram
    participant UI as User Interface
    participant FC as Fan Controller
    participant EC as EC Helper
    participant HW as Hardware

    Note over UI,HW: Fan Speed Update Process

    UI->>FC: Set Fan Speed
    activate FC
    FC->>FC: Validate Speed Range
    FC->>EC: Write Speed Value
    activate EC
    EC->>EC: Validate Register Access
    EC->>HW: Update Hardware Register
    activate HW
    HW-->>EC: Confirm Update
    deactivate HW
    EC-->>FC: Return Status
    deactivate EC
    FC-->>UI: Update Display
    deactivate FC

    Note over UI,HW: Temperature Monitoring Process

    loop Every 500ms
        HW->>EC: Temperature Update
        EC->>FC: Process Temperature
        FC->>FC: Calculate Required Speed
        FC->>EC: Adjust Speed if Needed
        EC->>HW: Update Fan Speed
    end
Loading

🔧 Technical Implementation

Fan Control Implementation

Speed Control

  • PWM-based control (0-100 range)
  • RPM monitoring (0-5000 RPM)
  • Temperature-based adjustment
  • Profile-based management

Temperature Monitoring

  • Real-time sensor reading (500ms intervals)
  • Temperature thresholds:
    • Warning: 60°C
    • Critical: 80°C
  • Automatic fan speed adjustment

Configuration Management

graph LR
    A[User Input] --> B[Config Manager]
    B --> C[Validation]
    C --> D[Storage]
    D --> E[Profile]
    E --> F[Hardware]
Loading

Key Technical Features

Hardware Communication

  • Direct EC register access
  • Low-level hardware control
  • Real-time monitoring
  • Hardware state validation

📋 Prerequisites

Flutter Development Environment

  • Flutter SDK (>=3.0.0)
  • Dart SDK (>=3.0.0)
  • Linux development tools:
    sudo apt update
    sudo apt install build-essential cmake ninja-build pkg-config libgtk-3-dev liblzma-dev

System Requirements

  • Linux system with MSI laptop
  • Required system permissions for EC access
  • D-Bus system service
  • System tray support
  • Hardware-specific drivers
  • ACPI EC Driver (acpi_ec)

🚀 Installation

Using the Installer Script (Recommended)

The Dragon Center comes with an automated installer script that handles all setup tasks:

# Clone the repository if you haven't already
git clone https://github.com/agnath18K/dragon_center_linux.git
cd dragon_center_linux

# Run the installer script with sudo
sudo ./install_dragon_service.sh

The installer script provides three options:

  1. Full Install - Installs the ACPI EC driver, adds your user to the 'ec' group, installs the .deb package, and sets up the systemd service
  2. Service-Only Install - Only sets up the systemd service (useful if you've already installed the driver and application)
  3. Uninstall - Removes the Dragon service, ACPI EC driver, and optionally the application files

Manual Installation (Advanced)

If you prefer to install components manually:

1. Install ACPI EC Driver

# Clone the acpi_ec repository
git clone https://github.com/agnath18K/acpi_ec.git
cd acpi_ec

# Install build dependencies
sudo apt update
sudo apt install build-essential linux-headers-$(uname -r)

# Install the driver
sudo ./install.sh

# Add your user to the ec group (required for EC access)
sudo usermod -a -G ec $USER

Note: You'll need to log out and back in for the group changes to take effect.

2. Install Dragon Center Application

# Install the package
sudo dpkg -i debian/packages/dragoncenter_1.0.1_amd64.deb

3. Configure Systemd Service

Create a systemd service file at /etc/systemd/system/dragon-service.service:

[Unit]
Description=Flutter Binary Service for Dragon
After=display-manager.service
Wants=display-manager.service

[Service]
Type=simple
User=root
ExecStartPre=/bin/bash -lc "xhost +SI:localuser:root"
ExecStartPre=/bin/sleep 10
ExecStart=/usr/local/lib/dragoncenter/dragon
WorkingDirectory=/usr/local/lib/dragoncenter
Restart=always
RestartSec=5
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/YOUR_USERNAME/.Xauthority
ExecStop=/bin/kill -s SIGTERM $MAINPID

[Install]
WantedBy=graphical.target

Then enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable dragon-service.service
sudo systemctl start dragon-service.service

Troubleshooting

If you encounter any issues with EC access:

  1. Verify the acpi_ec driver is loaded:
lsmod | grep acpi_ec
  1. Check driver status:
dmesg | grep acpi_ec
  1. Verify device file permissions:
ls -l /dev/ec*
  1. Check your group membership:
groups

🔧 Configuration

Profile Types

Universal Profile

  • Pre-configured settings
  • Automatic temperature management

Custom Profile

  • User-defined fan curves
  • Temperature thresholds
  • Custom monitoring options

Advanced Settings

Fan Control

  • Custom fan curves
  • Temperature thresholds
  • Minimum/maximum speeds

🏗️ Project Structure

lib/
├── core/
│   ├── presentation/    # UI components
│   │   ├── pages/      # Application pages
│   │   ├── widgets/    # Reusable widgets
│   │   └── themes/     # UI themes
│   ├── services/       # Business logic
│   │   ├── setup/      # Setup services
│   │   ├── fan/        # Fan control
│   │   └── system/     # System integration
│   └── utils/          # Helper functions
│       ├── ec/         # EC communication
│       ├── config/     # Configuration
│       └── logging/    # Logging system
├── models/             # Data models
│   ├── fan/           # Fan-related models
│   ├── system/        # System models
│   └── config/        # Configuration models
├── shared/            # Shared components
│   ├── widgets/       # Common widgets
│   ├── constants/     # Constants
│   └── types/         # Type definitions
└── main.dart          # Application entry point

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Development Guidelines

  • Follow Flutter's style guide
  • Add tests for new features
  • Update documentation
  • Maintain backward compatibility
  • Handle errors gracefully

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • MSI for their laptop hardware
  • Flutter team for the amazing framework
  • All contributors who have helped shape this project
  • Open-source community for inspiration and tools

Made with ❤️ for MSI laptop users

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages