cleansys-gui 0.6.4

CleanSys β€” desktop GUI for system cleanup on Linux, macOS, and Windows (Iced)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# CleanSys - Modern System Cleaner (Linux, macOS, Windows)

[![Crates.io](https://img.shields.io/crates/v/cleansys)](https://crates.io/crates/cleansys)
[![Documentation](https://docs.rs/cleansys/badge.svg)](https://docs.rs/cleansys)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Release](https://github.com/sorinirimies/cleansys/actions/workflows/release.yml/badge.svg)](https://github.com/sorinirimies/cleansys/actions/workflows/release.yml)
[![CI](https://github.com/sorinirimies/cleansys/actions/workflows/ci.yml/badge.svg)](https://github.com/sorinirimies/cleansys/actions/workflows/ci.yml)

**CleanSys** is a modern Linux system-cleanup utility available as both a terminal UI (Ratatui) and a desktop GUI (Iced). It helps you safely remove unnecessary files, clean caches, and free up disk space with real-time progress tracking.

## 🧱 Project Structure

CleanSys is a Cargo workspace with three crates:

| Crate | Binary | Description |
|-------|--------|-------------|
| [`cleansys-core`]crates/cleansys-core | *(library)* | Framework-free domain logic: cleaners, permission checks, formatting, sudo auth β€” shared by both front-ends |
| [`cleansys-tui`]crates/cleansys-tui | `cleansys` | Ratatui terminal UI + CLI (the original CleanSys experience) β€” published to crates.io as `cleansys` |
| [`cleansys-gui`]crates/cleansys-gui | `cleansys-gui` | Iced desktop GUI |

## 🎬 Demo

### Main Demo
![CleanSys Demo](demo

## ✨ Features

### πŸ›‘οΈ Safety
- **Confirmation dialog** before any destructive run (TUI and GUI) β€” lists exactly what's selected, with an option to disable prompts (`y` in the TUI)
- **Preview / dry-run mode** β€” measure real sizes and paths that *would* be cleaned without deleting anything (`d` in the TUI, "Preview" button in the GUI)
- **Progress tracking** β€” live per-item status plus an overall progress bar/percentage while a run is in flight
- **Desktop notifications** on completion (Linux/macOS/Windows)

### 🎨 Modern Terminal UI
- **Beautiful Interface**: Built with [Ratatui]https://github.com/ratatui-org/ratatui for a smooth, modern experience
- **Interactive Checkboxes**: Easy selection using [tui-checkbox]https://crates.io/crates/tui-checkbox library
- **Animated loading spinner**: [tui-spinner]https://crates.io/crates/tui-spinner renders a live braille spinner in the title bar while a cleaning run is in progress
- **Multiple Chart Types**: Toggle between Bar Chart, Pie Chart (by count), and Pie Chart (by size) β€” rendered directly by [tui-piechart]https://crates.io/crates/tui-piechart, with no local pie-drawing code of our own
- **Split-View Progress**: Detailed status information with real-time updates
- **Animated Indicators**: Loading spinners, progress bars, and status icons
- **Responsive Design**: Automatically adapts to any terminal size
- **Real-time Resize**: Handles terminal resizing without losing state

### 🧹 User-Level Cleaning (Linux, macOS, Windows)
- Browser caches β€” Firefox, Chrome/Chromium, Edge, Safari (real per-platform paths, not guesses)
- Application caches
- Thumbnail/preview caches
- Temporary files owned by the current user
- Package manager caches (pip, npm, cargo)
- Trash / Recycle Bin (Linux XDG trash, macOS `~/.Trash`, Windows Recycle Bin via Shell32)

### πŸ”§ System-Level Cleaning (platform-appropriate, some require root/admin)
- **Linux**: apt/pacman/dnf caches, rotated logs + journald vacuum, `/var/cache`, old kernels, crash reports
- **macOS**: Homebrew cache (never run as root!), Xcode DerivedData, unavailable iOS/watchOS/tvOS Simulator caches, rotated system logs, diagnostic/crash reports
- **Windows**: Windows Update download cache, `C:\Windows\Temp`, Recycle Bin (via the same Shell32 API Explorer's "Empty Recycle Bin" uses β€” no Administrator required for the current user's own bin)

Every cleaner reports **real measured sizes** β€” no estimates or guesses β€” and the detailed view/GUI activity log lists exactly which files/directories were removed and how many bytes each one freed.

### πŸ›‘οΈ Safe by Default
- Never removes system-critical files
- Confirms before running operations
- Detailed logs of all actions
- Shows exactly what will be cleaned
- Individual cleaner selection

## πŸ“¦ Installation

### From crates.io

```bash
# Terminal UI + CLI
cargo install cleansys

# Desktop GUI
cargo install cleansys-gui
```

### From source

```bash
git clone https://github.com/sorinirimies/cleansys
cd cleansys

# Build everything
cargo build --workspace --release

# Or install just one front-end
cargo install --path crates/cleansys-tui
cargo install --path crates/cleansys-gui
```

See [`justfile`](justfile) for the full list of development tasks (`just --list`).

## πŸš€ Usage

### Interactive TUI (Default)

Simply run CleanSys to launch the interactive terminal interface:

```bash
# User-level cleaning
cleansys

# System-level cleaning (requires root)
sudo cleansys
```

### Desktop GUI

Prefer a graphical interface? Launch the Iced-based desktop app instead:

```bash
cleansys-gui
```

It presents the exact same cleaners as the TUI (shared via `cleansys-core`) with checkboxes per category, a "Run selected" button, and a live activity log. Selections are remembered across restarts. System cleaners will prompt for your sudo password (Unix) or an "Administrator required" notice with a one-click relaunch (Windows) the first time they're needed.

- **Confirm before cleaning**: clicking "Run selected" shows exactly what's about to be deleted before anything happens.
- **Preview**: click "Preview" to see real sizes/paths that would be cleaned without deleting anything.
- **Progress bar**: a live progress bar and "N/M" counter while a run (or preview) is in flight.
- **Global selection**: "Select all" / "Select none" buttons work across every category, not just the active tab.
- **Desktop notification** when a run finishes.

The top bar includes a **theme selector** with 43 built-in themes (Dracula, Nord, Solarized, Gruvbox, Catppuccin, Tokyo Night, Kanagawa, Rose Pine, and more) β€” pick one from the dropdown and it's applied instantly and remembered across restarts (saved to `~/.config/cleansys/settings.json`).

### Command-Line Interface

```bash
# Run terminal UI explicitly
cleansys tui

# Run text-based interactive menu
cleansys menu

# Run user-level cleaners with confirmation
cleansys user

# Run user-level cleaners without prompts
cleansys user --yes

# Run system-level cleaners (requires root)
sudo cleansys system

# Run system cleaners without prompts
sudo cleansys system --yes

# List all available cleaners
cleansys list

# Show verbose output
cleansys --verbose
```

## ⌨️ Terminal UI Controls

### Navigation
- `↑/↓` or `j/k`: Navigate items
- `Tab/Shift+Tab`: Switch between categories
- `j/k`: Scroll detailed items list (vi-style)
- `PgUp/PgDn`: Scroll operation log
- `Home/End`: Jump to first/last item

### Actions
- `Space`: Toggle selection
- `Enter`: Run selected cleaners (shows a confirmation overlay first, unless disabled)
- `d`: Preview selected cleaners (dry-run β€” measures real sizes/paths, deletes nothing)
- `a`: Select all in current category
- `n`: Deselect all in current category
- `A`: Select all across every category
- `N`: Deselect all across every category
- `y`: Toggle confirmation prompts on/off
- `ESC`: Cancel operation, close overlay, or return to menu
- `q`: Exit application

### View Controls
- `c`: Cycle chart types (Bar β†’ Pie Count β†’ Pie Size)
- `m`: Toggle compact mode
- `v`: Cycle view modes (Standard/Compact/Detailed/Performance)
- `p`: Toggle performance statistics
- `s`: Toggle auto-scroll log
- `/`: Toggle search in detailed view
- `?`: Show/hide help

## πŸ“± Responsive Design

CleanSys features a fully responsive terminal interface with multiple breakpoints:

| Terminal Width | Layout Features |
|---------------|----------------|
| < 60 columns | Minimal UI, chart hidden, essential information only |
| 60-79 columns | Compact layout with reduced chart |
| 80-119 columns | Balanced layout with full chart |
| 120+ columns | Spacious layout with maximum information density |

## 🎯 View Modes

- **Standard Mode**: Balanced layout with full feature visibility (default)
- **Compact Mode**: Condensed layout for smaller terminals (<25 rows)
- **Detailed Mode**: Maximum information density with extended statistics
- **Performance Mode**: Focus on operation metrics and real-time monitoring

## πŸ“Š Chart Visualization

Press `c` to cycle through different chart types:

1. **Bar Chart**: Traditional vertical bar chart showing cleaned items
2. **Pie Chart (Count)**: Distribution by number of items cleaned
3. **Pie Chart (Size)**: Distribution by bytes cleaned

All charts automatically adapt to terminal size and include:
- Percentages
- Legends
- Color coding
- Smart label positioning

## πŸ” Detailed View

After cleaning operations, view comprehensive details:
- Complete list of cleaned files and directories
- Full file paths
- Individual file sizes
- Timestamps
- Scrollable with `j/k` or `PgUp/PgDn`
- Search functionality with `/`

## πŸ“ Examples

### Interactive TUI

```bash
# Launch TUI (default behavior)
cleansys

# Navigate with arrow keys
# Select cleaners with Space
# Press Enter to run
```

### Quick Clean

```bash
# Clean user caches without prompts
cleansys user --yes

# Clean system caches with verbose output
sudo cleansys system --verbose --yes
```

### List Available Cleaners

```bash
cleansys list
```

Output:
```
AVAILABLE CLEANERS

User cleaners (no root required):
  β€’ Browser Caches
  β€’ Application Caches
  β€’ Thumbnail Caches
  ...

System cleaners (root required):
  β€’ Package Manager Caches
  β€’ System Logs
  β€’ System Caches
  ...
```

## πŸ—οΈ Architecture

CleanSys is a Cargo workspace of three crates β€” see [Project Structure](#-project-structure) above. Rough internal layout:

```
crates/
β”œβ”€β”€ cleansys-core/           # Shared, framework-free logic
β”‚   └── src/
β”‚       β”œβ”€β”€ cleaners/        # user_cleaners.rs, system_cleaners.rs, cleaned_item.rs
β”‚       β”œβ”€β”€ model.rs         # CleanerItem, CleanerCategory, Status, load_categories()
β”‚       β”œβ”€β”€ auth.rs          # Sudo authentication helper
β”‚       └── utils.rs         # Permissions, formatting, confirmation prompts
β”œβ”€β”€ cleansys-tui/            # Ratatui TUI + CLI (binary: cleansys)
β”‚   └── src/
β”‚       β”œβ”€β”€ app.rs           # Application state and key-handling logic
β”‚       β”œβ”€β”€ events.rs        # Terminal input/resize event handling
β”‚       β”œβ”€β”€ render.rs        # UI rendering logic
β”‚       β”œβ”€β”€ pie_chart.rs     # Thin adapter: our data -> tui-piechart::PieChart (no local drawing logic)
β”‚       β”œβ”€β”€ menu.rs          # Text-based interactive menu
β”‚       └── components/      # Reusable widgets (password prompt)
└── cleansys-gui/            # Iced desktop GUI (binary: cleansys-gui)
    └── src/
        β”œβ”€β”€ state.rs          # Application state
        β”œβ”€β”€ update.rs         # Elm-style update logic
        β”œβ”€β”€ view.rs           # Rendering (tabs, cards, activity log)
        └── icons.rs          # Bootstrap icon glyph constants
```

## πŸ–₯️ Platform Support

Cleaners are **real and platform-native** on every OS β€” not just Linux paths
that happen to compile elsewhere. Each cleaner resolves OS-appropriate
locations (see [`cleansys-core::cleaners::platform`](crates/cleansys-core/src/cleaners/platform.rs))
and measures real freed bytes (no estimates).

| Platform | `cleansys` (TUI/CLI) | `cleansys-gui` | User cleaners | System cleaners |
|----------|:---:|:---:|-------|-------|
| Linux (x86_64, aarch64) | βœ… | βœ… | Firefox/Chrome/Chromium caches, `~/.cache`, thumbnails, `/tmp`, pip/npm/cargo caches, XDG Trash | apt/pacman/dnf caches, rotated logs + journald vacuum, `/var/cache`, old kernels, crash reports (root required) |
| macOS (Intel + Apple Silicon) | βœ… | βœ… | Firefox/Chrome/Safari caches, `~/Library/Caches`, QuickLook thumbnails, `$TMPDIR`, pip/npm/cargo caches, `~/.Trash` | Homebrew cache (**not** root β€” brew refuses to run as root), Xcode DerivedData, unavailable Simulator caches, rotated system logs, diagnostic/crash reports (root required) |
| Windows (x86_64) | βœ… | βœ… | Chrome/Edge/Firefox caches, Windows INetCache/CrashDumps, thumbnail cache, `%TEMP%`, pip/npm/cargo caches | Windows Update download cache, `C:\Windows\Temp` (Administrator), Recycle Bin (via Shell32, no Administrator needed for your own bin) |

Windowing / desktop-environment support for `cleansys-gui` (via [Iced](https://iced.rs)/winit):
- **Linux**: X11 and Wayland (both enabled by default)
- **macOS**: native Cocoa/AppKit windowing (Intel + Apple Silicon, universal binary in releases)
- **Windows**: native Win32 windowing

The terminal UI (`cleansys`, via [Ratatui](https://github.com/ratatui-org/ratatui)/[Crossterm](https://github.com/crossterm-rs/crossterm)) works in any terminal emulator on any of the three platforms.

See [Releases](https://github.com/sorinirimies/cleansys/releases) for pre-built binaries: Linux `.deb`/`.rpm`/AppImage, Windows NSIS installer, and a universal macOS `.dmg`.

## πŸ§ͺ Testing

Run the test suite:

```bash
# Run all tests
cargo test

# Run with output
cargo test -- --nocapture

# Run specific test module
cargo test --test integration_tests
```

## πŸ€– Automated Maintenance

A nightly Gitea Actions job (`.gitea/workflows/deps-update.yml`) upgrades every
workspace dependency pin, runs the full quality gate (fmt, clippy, test), andβ€”
if anything actually changedβ€”**automatically cuts a new patch release**: it
commits the dependency bump, then bumps the workspace version (`X.Y.Z` β†’
`X.Y.Z+1`), regenerates `CHANGELOG.md`, and pushes the tag directly to `main`.
No PR, no manual approval β€” pushing the tag triggers the normal Release
workflow (build, package, crates.io publish, AUR update). If the quality gate
fails at any point the job simply stops; nothing broken is ever released.

Run the same flow locally with `just auto-patch-release`.

## 🀝 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/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

## πŸ“„ License

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

## πŸ”— Links

- [Repository]https://github.com/sorinirimies/cleansys
- [Crates.io]https://crates.io/crates/cleansys
- [Documentation]https://docs.rs/cleansys

## πŸŽ₯ Demo Creation

CleanSys uses [VHS](https://github.com/charmbracelet/vhs) to create terminal session recordings. The demo tapes showcase:

- **`demo.tape`**: Main demo showing both user and system cleaners
- **`userland-cleaners.tape`**: Detailed walkthrough of user-level cleaning (no root required)
- **`system-cleaners.tape`**: Detailed walkthrough of system-level cleaning (requires authentication)

### Generating Demos

```bash
# Install VHS (requires Go)
# See: https://github.com/charmbracelet/vhs#installation

# Generate main demo
just vhs

# Generate userland cleaners demo
just vhs-userland

# Generate system cleaners demo
just vhs-system

# Generate all demos
just vhs-all

# Clean generated demos
just vhs-clean
```

All generated GIF files are output to `demo/target/` and are git-ignored.

## πŸ—ΊοΈ Roadmap / Ideas

Things that would be natural next steps for the project (contributions welcome!):

- **Scheduled/background cleaning** β€” a small daemon or OS-native scheduler (systemd timer / launchd / Task Scheduler) integration to auto-clean on a cadence.
- **Pluggable/custom cleaners** β€” user-defined cleaner rules via a TOML config (glob patterns + safety checks), loaded by `cleansys-core` and shared by both front-ends.
- **GUI disk-usage chart** β€” port the TUI's pie/bar chart (`tui-piechart`) to an Iced `Canvas` widget in `cleansys-gui` for visual parity.
- **Light/dark auto-detection** for the GUI theme (follow OS preference by default, falling back to the manual picker).
- **Localization (i18n)** for both UIs.
- **JSON output** for `cleansys list` / `cleansys user --yes` etc., to make the CLI scriptable.
- **AUR / winget / Homebrew formulae** for easier installation (AUR `PKGBUILD` scaffold already included under `packaging/aur/`).
- **TUI selection persistence** β€” the GUI already remembers checked cleaners across restarts (`~/.config/cleansys/settings.json`); the TUI could opt into the same `tui-settings.json` file.
- **Branded icon/artwork** β€” `packaging/windows/cleansys.ico` and `packaging/macos/cleansys.icns` currently fall back to a placeholder/no icon; real artwork would polish the installers/DMG.

## πŸ™ Acknowledgments

- [Ratatui]https://github.com/ratatui-org/ratatui - Terminal UI framework
- [tui-checkbox]https://crates.io/crates/tui-checkbox - Checkbox widget library
- [tui-spinner]https://crates.io/crates/tui-spinner - Animated loading spinner widget
- [tui-piechart]https://crates.io/crates/tui-piechart - Pie chart visualization widget
- [Crossterm]https://github.com/crossterm-rs/crossterm - Cross-platform terminal manipulation
- [Iced]https://iced.rs - Cross-platform Rust GUI framework powering `cleansys-gui`
- [iced_fonts]https://crates.io/crates/iced_fonts - Bootstrap icon font for the GUI
- [VHS]https://github.com/charmbracelet/vhs - Terminal session recorder for creating demos

---

**Note**: Always review what will be cleaned before running system-level operations. While CleanSys is designed to be safe, it's good practice to understand what's being removed from your system.