# bauca/graphics-switcher architecture

> Architecture diagram of the GitHub repository bauca/graphics-switcher, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bauca/graphics-switcher
- Repository: https://github.com/bauca/graphics-switcher

## Overview

##### Project type and purpose
- This is an open-source CLI tool (a single Bash script named “Graphics-Switcher”) whose sole mission is to detect and switch between NVIDIA and Intel GPUs on Ubuntu 16.04, and to apply a screen-tearing fix when using the Intel driver.

##### File structure
- Top-level entries are all documentation and one executable script:
- Graphics-Switcher (the Bash script)
- README.md, CONTRIBUTING.md, CodeOfConduct.md, IssueTemplate.md, LICENSE
- No subdirectories or backend/frontend split—this is a self-contained shell utility.

##### README for additional insights
- Key dependencies: Ubuntu 16.04, NVIDIA proprietary driver (375.66), mesa-utils (provides glxinfo), optionally prime-select
- Workflow: the user invokes the script; it queries the active GPU; it switches the driver; if Intel is selected, it also applies a tear-fix.

##### Detailed breakdown
- Layer 1 (User Layer): “CLI Prompt” → calls → “Graphics-Switcher”
- Layer 2 (Script Layer): script’s internal phases:
- Detect → Switch → Fix
- Layer 3 (Utility Layer): glxinfo, prime-select
- Layer 4 (OS Layer):
- GPU Drivers (NVIDIA, Intel)
- X Server / Display Manager

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User Layer"
        CLI["CLI Prompt"]:::user
    end

    subgraph "Core Script" 
        GS["Graphics-Switcher"]:::script
    end

    subgraph "Utility Layer"
        GI["glxinfo (mesa-utils)"]:::utility
        PS["prime-select (optional)"]:::utility
    end

    subgraph "OS Subsystems"
        NVIDIA["NVIDIA Driver"]:::os
        INTEL["Intel Mesa DRI"]:::os
        XSERVER["X Server / Display Manager"]:::os
        PKG["apt/dpkg Package Manager"]:::os
    end

    subgraph "Documentation"
        README["README.md"]:::docs
        CONTRIBUTING["CONTRIBUTING.md"]:::docs
        CODEOFD["CodeOfConduct.md"]:::docs
        ISSUE["IssueTemplate.md"]:::docs
        LICENSE["LICENSE"]:::docs
    end

    CLI -->|"invoke"| GS
    GS -->|"detect GPU"| GI
    GS -->|"optional detection"| PS
    GS -->|"switch driver"| NVIDIA
    GS -->|"switch driver"| INTEL
    GS -->|"apply tear-fix"| XSERVER
    GS -->|"installation interactions"| PKG

    click GS "https://github.com/bauca/graphics-switcher/tree/master/Graphics-Switcher"
    click README "https://github.com/bauca/graphics-switcher/blob/master/README.md"
    click CONTRIBUTING "https://github.com/bauca/graphics-switcher/blob/master/CONTRIBUTING.md"
    click CODEOFD "https://github.com/bauca/graphics-switcher/blob/master/CodeOfConduct.md"
    click ISSUE "https://github.com/bauca/graphics-switcher/blob/master/IssueTemplate.md"
    click LICENSE "https://github.com/bauca/graphics-switcher/tree/master/LICENSE"

    classDef user fill:#FFF2CC,stroke:#E0A800,color:#333;
    classDef script fill:#D0E6FF,stroke:#357EDD,color:#000;
    classDef utility fill:#DFFFE0,stroke:#28A745,color:#000;
    classDef os fill:#E8E8E8,stroke:#6C757D,color:#000;
    classDef docs fill:#FFE0E6,stroke:#CC2950,color:#000;
```
