# jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module architecture

> Architecture diagram of the GitHub repository jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module
- Repository: https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module

## Overview

##### Project type and purpose
- This is a hybrid system consisting of a Linux kernel module (C code) that extends the Acer-WMI driver to support gaming-keyboard backlight (RGB) and “turbo” mode, plus a suite of user-space tools (Python scripts, shell scripts, packaging metadata) for building, installing, configuring, and driving that module from user space.

##### File structure
- Top-level “src/” contains the C source for the kernel module (facer.c).
- “dkms.conf” plus the Makefile support building the module via DKMS or ad-hoc make/insmod.
- Shell scripts (install.sh, install_service.sh, install_openrc.sh, uninstall.sh, uninstall_service.sh, uninstall_openrc.sh) automate building, installing, registering as a systemd or OpenRC service, and unloading.
- Python CLI tools (keyboard.py, facer_rgb.py) communicate with the deployed module via a character device node (/dev/acer-gkbbl-0).
- ArchLinux-specific packaging under “ArchLinux-bin-pkg/” contains a PKGBUILD and install hooks for binary package distribution.
- GitHub configuration (.github/workflows) handles CI tasks (CodeQL analysis) and contribution templates.

##### Key README insights
- The module uses WMI/ACPI to talk to the hardware.
- On load, it registers a char-device interface for RGB control.
- User tools leverage that interface to provide static/dynamic RGB effects and toggle Turbo mode.
- Installation can be one-off or registered as a service (systemd or OpenRC).
- DKMS support ensures the module is rebuilt across kernel updates.

##### Components
a. Kernel-space component
- “acer_predator_wmi” module (src/facer.c)
- Uses the Linux WMI framework (ACPI/WMI calls) to send RGB and Turbo commands to the embedded controller.
- Exposes a character device node (/dev/acer-gkbbl-0).

b. User-space components
- Python CLI (facer_rgb.py) – low-level RGB control API
- Python wrapper (keyboard.py) – user-friendly interactive CLI
- Shell scripts – install.sh / uninstall.sh for ad-hoc use; install_service.sh + uninstall_service.sh to register as systemd service; install_openrc.sh for OpenRC.
- ArchLinux PKGBUILD / packaging scripts – build and distribute as a distro package.

c. Build and deploy pipeline
- Development source → Makefile + dkms.conf → DKMS build (or direct kernel build via “make”) → insmod/modprobe → module loaded in kernel.
- “install.sh” or service scripts wrap that pipeline and also copy config and start services.
- GitHub Actions workflow (codeql-analysis.yml) runs static analysis on push/pull requests.

d. External dependencies and services
- Linux kernel headers / gcc / make (build dependencies)
- Python runtime (for CLI scripts)
- rsync (for service installer)
- systemd or OpenRC init system for auto-start

##### Architectural patterns and design principles
- Clear separation of concerns: Kernel-space hardware interface vs user-space control logic.
- Extensibility: DKMS and packaging layers allow integration with different distros; Python scripts present a simple API for other tools (GUIs or custom scripts).
- Modularity: Single-file kernel module + generic character-device interface + script wrappers.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Kernel Space"
        KMOD["acer_predator_wmi kernel module<br/>C, WMI/ACPI, char device /dev/acer-gkbbl-0"]:::kernel
        DKMS["dkms.conf<br/>DKMS configuration"]:::deploy
        MAKE["Makefile<br/>Build support"]:::deploy
    end

    subgraph "User Space"
        CLI1["facer_rgb.py<br/>Python3 RGB API"]:::user
        CLI2["keyboard.py<br/>Python3 interactive CLI"]:::user

        subgraph "Ad-hoc Scripts" 
            INSTA["install.sh<br/>Bash install"]:::deploy
            UNSTA["uninstall.sh<br/>Bash uninstall"]:::deploy
        end

        subgraph "Service Scripts"
            INSTSERV["install_service.sh<br/>systemd service"]:::deploy
            UNTSERV["uninstall_service.sh<br/>systemd remove"]:::deploy
            INSTOPEN["install_openrc.sh<br/>OpenRC service"]:::deploy
        end

        subgraph "Packaging"
            PKGBUILD["PKGBUILD<br/>ArchLinux pkg"]:::deploy
            HOOK["acer-predator-turbo-rgb-git.install<br/>install hook"]:::deploy
            MAKEPKG["makepkg.sh<br/>build helper"]:::deploy
        end
    end

    subgraph "CI/CD & Docs"
        CI["codeql-analysis.yml<br/>GitHub Actions"]:::external
        ISSUE["issue-template.md<br/>Contribution template"]:::external
        README["README.md<br/>Project documentation"]:::external
    end

    subgraph "External Dependencies"
        HEADERS["Linux kernel headers<br/>gcc, make"]:::external
        PY["Python runtime"]:::external
        RSYNC["rsync"]:::external
        INIT["systemd / OpenRC"]:::external
        HW["ACPI/HW firmware"]:::external
    end

    CLI1 -->|"ioctl/write/read"| KMOD
    CLI2 -->|"uses API"| KMOD
    KMOD -->|"WMI/ACPI calls"| HW

    DKMS -->|"on kernel upgrade rebuild"| KMOD
    MAKE -->|"make → insmod/modprobe"| KMOD

    INSTA -->|"build & install pipeline"| MAKE
    UNSTA -->|"uninstall pipeline"| MAKE

    INSTSERV -->|"register service & load"| MAKE
    UNTSERV -->|"unregister service"| MAKE
    INSTOPEN -->|"register OpenRC service"| MAKE

    INIT -->|"boot integration"| INSTSERV
    INIT -->|"boot integration"| INSTOPEN

    CI -->|"static analysis"| KMOD
    CI -->|"static analysis"| CLI1

    README -->|"describes architecture"| KMOD
    README -->|"describes architecture"| CLI1

    HEADERS -->|"build dependency"| MAKE
    PY -->|"runtime"| CLI1
    PY -->|"runtime"| CLI2
    RSYNC -->|"file sync"| INSTSERV
    RSYNC -->|"file sync"| INSTOPEN

    classDef kernel fill:#f88,stroke:#f00,color:#600;
    classDef user fill:#8cf,stroke:#06c,color:#036;
    classDef deploy fill:#afa,stroke:#0a0,color:#060;
    classDef external fill:#ddd,stroke:#888,color:#666;

    click KMOD "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/src/facer.c"
    click DKMS "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/dkms.conf"
    click MAKE "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/tree/main/Makefile"
    click CLI1 "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/facer_rgb.py"
    click CLI2 "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/keyboard.py"
    click INSTA "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/install.sh"
    click UNSTA "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/uninstall.sh"
    click INSTSERV "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/install_service.sh"
    click UNTSERV "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/uninstall_service.sh"
    click INSTOPEN "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/install_openrc.sh"
    click PKGBUILD "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/tree/main/ArchLinux-bin-pkg/PKGBUILD"
    click HOOK "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/ArchLinux-bin-pkg/acer-predator-turbo-rgb-git.install"
    click MAKEPKG "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/ArchLinux-bin-pkg/makepkg.sh"
    click CI "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/.github/workflows/codeql-analysis.yml"
    click ISSUE "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/.github/ISSUE_TEMPLATE/issue-template.md"
    click README "https://github.com/jafarakhondali/acer-predator-turbo-and-rgb-keyboard-linux-module/blob/main/README.md"
```
