# 3c6c/theme-switcher-linux architecture

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

- Interactive diagram: https://gitdiagram.com/3c6c/theme-switcher-linux
- Repository: https://github.com/3c6c/theme-switcher-linux

## Overview

`thm` is a Linux wallpaper-driven theme switcher. The main workflow is a user invoking the CLI to extract or reuse a wallpaper palette, persist it, update supported application configs, set the desktop background, and reload programs; `current` and `show` provide status and preview paths. A resident picker is a separate documented entry point that applies selections through `thm set`. The picker, state, and reload implementations were not sampled, so their internal links are limited to documented behavior and visible CLI calls.

Main entry points: [`src/main.rs`](https://github.com/3c6c/theme-switcher-linux/blob/master/src/main.rs) (thm CLI), [`src/edit.rs`](https://github.com/3c6c/theme-switcher-linux/blob/master/src/edit.rs) (Config editing), [`src/hooks.rs`](https://github.com/3c6c/theme-switcher-linux/blob/master/src/hooks.rs) (Program reloads), [`src/bin/thm-picker.rs`](https://github.com/3c6c/theme-switcher-linux/blob/master/src/bin/thm-picker.rs) (Wallpaper picker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry points"]
  node_cli["thm CLI<br/>[main.rs]"]
  node_picker["Wallpaper picker<br/>[thm-picker.rs]"]
end

subgraph group_palette["Palette engine"]
  node_extract["Palette extraction<br/>[extract.rs]"]
  node_color["Color math<br/>[color.rs]"]
end

subgraph group_apply["Apply and persist"]
  node_cache[("Palette cache<br/>[state.rs]")]
  node_state[("Theme state<br/>[state.rs]")]
  node_config_edit["Config editing<br/>[edit.rs]"]
end

subgraph group_integrations["Desktop integrations"]
  node_reload["Program reloads<br/>[hooks.rs]"]
  node_desktop["Desktop background"]
  node_alacritty["Alacritty config"]
  node_polybar["Polybar config"]
  node_dunst["Dunst config"]
  node_gtk["GTK styles"]
  node_dmenu["dmenu wrapper"]
  node_xresources["XResources"]
end

node_user(("User"))
node_wallpaper["Wallpaper image"]
node_running_apps["Running programs"]

node_user -->|"invokes"| node_cli
node_user -->|"selects wallpaper"| node_picker
node_picker -->|"applies via"| node_cli
node_cli -->|"reads"| node_wallpaper
node_cli -->|"looks up palette"| node_cache
node_cli -->|"extracts palette"| node_extract
node_extract -->|"uses color math"| node_color
node_cli -->|"stores palette"| node_cache
node_cli -->|"writes theme state"| node_state
node_cli -->|"edits configs"| node_config_edit
node_config_edit -->|"updates"| node_alacritty
node_config_edit -->|"updates"| node_polybar
node_config_edit -->|"updates"| node_dunst
node_config_edit -->|"writes styles"| node_gtk
node_config_edit -->|"creates wrapper"| node_dmenu
node_state -->|"writes colors"| node_xresources
node_cli -->|"sets background"| node_desktop
node_cli -->|"requests reload"| node_reload
node_reload -->|"merges"| node_xresources
node_reload -->|"restarts or reloads"| node_running_apps

click node_cli "https://github.com/3c6c/theme-switcher-linux/blob/master/src/main.rs"
click node_picker "https://github.com/3c6c/theme-switcher-linux/blob/master/src/bin/thm-picker.rs"
click node_extract "https://github.com/3c6c/theme-switcher-linux/blob/master/src/extract.rs"
click node_color "https://github.com/3c6c/theme-switcher-linux/blob/master/src/color.rs"
click node_cache "https://github.com/3c6c/theme-switcher-linux/blob/master/src/state.rs"
click node_state "https://github.com/3c6c/theme-switcher-linux/blob/master/src/state.rs"
click node_config_edit "https://github.com/3c6c/theme-switcher-linux/blob/master/src/edit.rs"
click node_reload "https://github.com/3c6c/theme-switcher-linux/blob/master/src/hooks.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_picker,node_user toneBlue
class node_extract,node_color toneAmber
class node_cache,node_state,node_config_edit toneMint
class node_reload,node_desktop,node_alacritty,node_polybar,node_dunst,node_gtk,node_dmenu,node_xresources toneRose
class node_wallpaper,node_running_apps toneIndigo
```

## Components

### User entry points

- [thm CLI](https://github.com/3c6c/theme-switcher-linux/blob/master/src/main.rs): `src/main.rs`
- [Wallpaper picker](https://github.com/3c6c/theme-switcher-linux/blob/master/src/bin/thm-picker.rs): `src/bin/thm-picker.rs`

### Palette engine

- [Palette extraction](https://github.com/3c6c/theme-switcher-linux/blob/master/src/extract.rs): `src/extract.rs`
- [Color math](https://github.com/3c6c/theme-switcher-linux/blob/master/src/color.rs): `src/color.rs`

### Apply and persist

- [Palette cache](https://github.com/3c6c/theme-switcher-linux/blob/master/src/state.rs): `src/state.rs`
- [Theme state](https://github.com/3c6c/theme-switcher-linux/blob/master/src/state.rs): `src/state.rs`
- [Config editing](https://github.com/3c6c/theme-switcher-linux/blob/master/src/edit.rs): `src/edit.rs`

### Desktop integrations

- [Program reloads](https://github.com/3c6c/theme-switcher-linux/blob/master/src/hooks.rs): `src/hooks.rs`
- **Desktop background**
- **Alacritty config**
- **Polybar config**
- **Dunst config**
- **GTK styles**
- **dmenu wrapper**
- **XResources**

### Other components

- **User**
- **Wallpaper image**
- **Running programs**

## Connections

- User → thm CLI: invokes (evidence: `README.md`)
- User → Wallpaper picker: selects wallpaper (evidence: `README.md`)
- Wallpaper picker → thm CLI: applies via (evidence: `README.md`)
- thm CLI → Wallpaper image: reads (evidence: `src/main.rs`)
- thm CLI → Palette cache: looks up palette (evidence: `src/main.rs`)
- thm CLI → Palette extraction: extracts palette (evidence: `src/main.rs`)
- Palette extraction → Color math: uses color math (evidence: `src/extract.rs`)
- thm CLI → Palette cache: stores palette (evidence: `src/main.rs`)
- thm CLI → Theme state: writes theme state (evidence: `src/main.rs`)
- thm CLI → Config editing: edits configs (evidence: `src/main.rs`)
- Config editing → Alacritty config: updates (evidence: `README.md`)
- Config editing → Polybar config: updates (evidence: `README.md`)
- Config editing → Dunst config: updates (evidence: `README.md`)
- Config editing → GTK styles: writes styles (evidence: `README.md`)
- Config editing → dmenu wrapper: creates wrapper
- Theme state → XResources: writes colors (evidence: `README.md`)
- thm CLI → Desktop background: sets background (evidence: `src/main.rs`)
- thm CLI → Program reloads: requests reload (evidence: `src/main.rs`)
- Program reloads → XResources: merges (evidence: `README.md`)
- Program reloads → Running programs: restarts or reloads (evidence: `README.md`)
