# emrnky/attack-shark-x6 architecture

> Architecture diagram of the GitHub repository emrnky/attack-shark-x6, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/emrnky/attack-shark-x6
- Repository: https://github.com/emrnky/attack-shark-x6

## Overview

Attack Shark X6 is a small Linux mouse-monitoring application. The tray process starts a HID event monitor and, when a supported link is available, a settings reader; their JSON output updates a GTK popup with battery, connection, and device settings. Internally, device discovery and HID I/O feed the X6 protocol layer, which uses report decoders and protocol constants. The excerpts show these runtime connections; the README documents udev permissions. Settings cannot be read over Bluetooth, as stated by the sampled status code.

Main entry points: [`core/hid.py`](https://github.com/emrnky/attack-shark-x6/blob/main/core/hid.py) (Device discovery and I/O), [`tray.py`](https://github.com/emrnky/attack-shark-x6/blob/main/tray.py) (Tray controller), [`core/x6.py`](https://github.com/emrnky/attack-shark-x6/blob/main/core/x6.py) (Mouse interface), [`core/bat.py`](https://github.com/emrnky/attack-shark-x6/blob/main/core/bat.py) (Event monitor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Tray and display"]
  node_tray["Tray controller<br/>[tray.py]"]
  node_popup["Settings popup<br/>[window.py]"]
end

subgraph group_monitor["Monitoring and settings"]
  node_battery_monitor["Event monitor<br/>[bat.py]"]
  node_settings_reader["Settings reader<br/>[status.py]"]
end

subgraph group_protocol["X6 HID protocol"]
  node_device_access["Device discovery and I/O<br/>[hid.py]"]
  node_mouse["Mouse interface<br/>[x6.py]"]
  node_decoders["Report and event decoding<br/>[decode.py]"]
  node_protocol_defs["Protocol definitions<br/>[defaults.py]"]
end

node_user(("Linux user"))
node_x6(("Attack Shark X6"))
node_linux_hid["Linux hidraw"]
node_udev_rule["Unprivileged access rule"]

node_user -->|"launches"| node_tray
node_tray -->|"spawns monitor"| node_battery_monitor
node_tray -->|"spawns reader"| node_settings_reader
node_tray -->|"updates and toggles"| node_popup
node_battery_monitor -->|"discovers and watches"| node_device_access
node_battery_monitor -->|"reads events"| node_mouse
node_settings_reader -->|"discovers device"| node_device_access
node_settings_reader -->|"reads settings"| node_mouse
node_mouse -->|"uses HID I/O"| node_device_access
node_mouse -->|"decodes reports"| node_decoders
node_decoders -->|"uses definitions"| node_protocol_defs
node_protocol_defs -->|"uses bus IDs"| node_device_access
node_x6 -->|"communicates via"| node_device_access
node_udev_rule -.->|"permits access"| node_linux_hid

click node_tray "https://github.com/emrnky/attack-shark-x6/blob/main/tray.py"
click node_popup "https://github.com/emrnky/attack-shark-x6/blob/main/window.py"
click node_battery_monitor "https://github.com/emrnky/attack-shark-x6/blob/main/core/bat.py"
click node_settings_reader "https://github.com/emrnky/attack-shark-x6/blob/main/core/status.py"
click node_device_access "https://github.com/emrnky/attack-shark-x6/blob/main/core/hid.py"
click node_mouse "https://github.com/emrnky/attack-shark-x6/blob/main/core/x6.py"
click node_decoders "https://github.com/emrnky/attack-shark-x6/blob/main/core/decode.py"
click node_protocol_defs "https://github.com/emrnky/attack-shark-x6/blob/main/core/defaults.py"
click node_udev_rule "https://github.com/emrnky/attack-shark-x6/blob/main/99-attacksharkx6.rules"

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_tray,node_popup,node_user toneBlue
class node_battery_monitor,node_settings_reader toneAmber
class node_device_access,node_mouse,node_decoders,node_protocol_defs toneMint
class node_x6,node_linux_hid toneIndigo
class node_udev_rule toneTeal
```

## Components

### Tray and display

- [Tray controller](https://github.com/emrnky/attack-shark-x6/blob/main/tray.py): `tray.py`
- [Settings popup](https://github.com/emrnky/attack-shark-x6/blob/main/window.py): `window.py`

### Monitoring and settings

- [Event monitor](https://github.com/emrnky/attack-shark-x6/blob/main/core/bat.py): `core/bat.py`
- [Settings reader](https://github.com/emrnky/attack-shark-x6/blob/main/core/status.py): `core/status.py`

### X6 HID protocol

- [Device discovery and I/O](https://github.com/emrnky/attack-shark-x6/blob/main/core/hid.py): `core/hid.py`
- [Mouse interface](https://github.com/emrnky/attack-shark-x6/blob/main/core/x6.py): `core/x6.py`
- [Report and event decoding](https://github.com/emrnky/attack-shark-x6/blob/main/core/decode.py): `core/decode.py`
- [Protocol definitions](https://github.com/emrnky/attack-shark-x6/blob/main/core/defaults.py): `core/defaults.py`

### Other components

- **Linux user**
- **Attack Shark X6**
- **Linux hidraw**
- [Unprivileged access rule](https://github.com/emrnky/attack-shark-x6/blob/main/99-attacksharkx6.rules): `99-attacksharkx6.rules`

## Connections

- Linux user → Tray controller: launches (evidence: `README.md`)
- Tray controller → Event monitor: spawns monitor (evidence: `tray.py`)
- Tray controller → Settings reader: spawns reader (evidence: `tray.py`)
- Tray controller → Settings popup: updates and toggles (evidence: `tray.py`)
- Event monitor → Device discovery and I/O: discovers and watches (evidence: `core/bat.py`)
- Event monitor → Mouse interface: reads events (evidence: `core/bat.py`)
- Settings reader → Device discovery and I/O: discovers device (evidence: `core/status.py`)
- Settings reader → Mouse interface: reads settings (evidence: `core/status.py`)
- Mouse interface → Device discovery and I/O: uses HID I/O (evidence: `core/x6.py`)
- Mouse interface → Report and event decoding: decodes reports (evidence: `core/x6.py`)
- Report and event decoding → Protocol definitions: uses definitions (evidence: `core/decode.py`)
- Protocol definitions → Device discovery and I/O: uses bus IDs (evidence: `core/defaults.py`)
- Attack Shark X6 → Device discovery and I/O: communicates via (evidence: `core/hid.py`)
- Unprivileged access rule → Linux hidraw: permits access (evidence: `README.md`)
