aboutsummarylogtreecommitdiffstats
path: root/README.md
blob: e3067ca614fcd3241527dbb7f2b6c665905f9fa9 (plain)
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
# SHIELD System Cleaner

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Shell: Bash](https://img.shields.io/badge/Shell-Bash-green.svg)](https://www.gnu.org/software/bash/)
[![Platform: Arch Linux](https://img.shields.io/badge/Platform-Arch%20Linux-1793D1.svg)](https://archlinux.org/)
[![AUR version](https://img.shields.io/aur/version/shield-cleaner.svg)](https://aur.archlinux.org/packages/shield-cleaner)

Advanced system maintenance tool for Arch Linux with interactive and automated cleaning capabilities.

## Features

- ๐Ÿงน **Comprehensive Cleaning**: Pacman cache, AUR cache, journal logs, thumbnails, user cache, temp files, trash, and RAM caches
- ๐ŸŽจ **Color-coded Output**: Beautiful visual feedback with icons and colors
- ๐Ÿ”ง **Flexible Modes**: Interactive prompts or fully automated operation
- ๐Ÿ“Š **Space Tracking**: Shows exactly how much space is freed
- ๐Ÿ” **Dry-run Mode**: Preview actions before executing
- ๐ŸŽฏ **Selective Cleanup**: Target specific operations
- ๐Ÿ“ˆ **Summary Reports**: Complete statistics after operation

## Quick Start

```bash
# Install via yay
yay -S shield-cleaner

# Run in interactive mode (prompts for each action)
shield-cleaner

# Run automated cleanup (no prompts)
shield-cleaner -a

# Preview what would be cleaned (dry-run)
shield-cleaner -d
```

## Installation

### Via Yay (Recommended)

```bash
yay -S shield-cleaner
```

### Via AUR

```bash
git clone https://aur.archlinux.org/shield-cleaner.git
cd shield-cleaner
makepkg -si
```

### Manual Installation from Source

```bash
git clone https://github.com/reyanshrajmishra/shield-cleaner.git
cd shield-cleaner
sudo make install
```

### Local User Installation

```bash
git clone https://github.com/reyanshrajmishra/shield-cleaner.git
cd shield-cleaner
make local-install
```
*Note: Ensure `~/.local/bin` is in your PATH*

## Usage

### Interactive Mode (Default)
```bash
shield-cleaner
```

### Automated Mode
```bash
shield-cleaner -a          # Clean everything automatically
shield-cleaner -y          # Auto-yes to all prompts
```

### Dry Run
```bash
shield-cleaner -d          # Preview what would be done
```

### Selective Cleaning
```bash
shield-cleaner --pacman --yay    # Clean package caches only
shield-cleaner --journal 100M    # Vacuum journal to 100MB
shield-cleaner --cache --temp    # Clear cache and temp files
```

### All Options
```bash
shield-cleaner [OPTIONS]

Options:
    -a, --all           Run all cleanups without prompting
    -y, --yes           Automatic yes to prompts
    -d, --dry-run       Show what would be done without doing it
    -v, --verbose       Enable verbose output
    -q, --quiet         Suppress non-essential output
    -h, --help          Show help message
    
    --pacman            Clean pacman cache only
    --yay               Clean yay cache only
    --journal [SIZE]    Vacuum journal logs (default: 50M)
    --thumbnails        Clear thumbnail cache only
    --cache             Clear user cache only
    --temp              Remove temp files only
    --trash             Empty trash only
    --ram               Drop RAM caches only
```

## What Gets Cleaned

| Operation | Description | Requires sudo |
|-----------|-------------|---------------|
| Pacman cache | Removes old/uninstalled package files | Yes |
| Yay cache | Cleans AUR helper cache | Yes |
| Journal logs | Vacuums systemd journal logs | Yes |
| Thumbnails | Removes `~/.cache/thumbnails` | No |
| User cache | Clears `~/.cache` directory | No |
| Temp files | Removes `/tmp` and `/var/tmp` files | Yes |
| Trash | Empties `~/.local/share/Trash` | No |
| RAM cache | Drops kernel page cache | Yes |

## Examples

```bash
# Weekly maintenance routine
shield-cleaner -a

# Check what would be cleaned
shield-cleaner -d -v

# Clean only package caches before system upgrade
shield-cleaner --pacman --yay

# Aggressive journal cleanup
shield-cleaner --journal 25M

# Quick cache cleanup (no sudo needed)
shield-cleaner --thumbnails --cache --trash
```

## Requirements

- **bash** - Shell interpreter
- **pacman** - Package manager
- **util-linux** - For journalctl
- **coreutils** - Core utilities
- **yay** (optional) - AUR helper

## Building from Source

### Prerequisites
Ensure you have `make` and `git` installed on your system.

### Build Commands

```bash
# Clone the repository
git clone https://github.com/reyanshrajmishra/shield-cleaner.git
cd shield-cleaner

# Test the script (dry-run mode)
make test

# Install system-wide (requires sudo)
sudo make install

# Install to custom prefix
sudo make install PREFIX=/usr/local

# Install for current user only
make local-install

# Create an Arch Linux package
makepkg -si

# Uninstall
sudo make uninstall

# Clean build artifacts
make clean
```

### Makefile Targets

| Target | Description |
|--------|-------------|
| `install` | Install to system (default: `/usr/local/bin`) |
| `uninstall` | Remove from system |
| `test` | Run dry-run test with verbose output |
| `local-install` | Install to `~/.local/bin` |
| `clean` | Remove build artifacts |

### Package Structure

```
shield-cleaner/
โ”œโ”€โ”€ shield-cleaner.sh     # Main executable script
โ”œโ”€โ”€ Makefile              # Build configuration
โ”œโ”€โ”€ PKGBUILD              # Arch Linux package specification
โ”œโ”€โ”€ LICENSE               # MIT License
โ”œโ”€โ”€ README.md             # Documentation
โ””โ”€โ”€ src/                  # Source symlinks for package building
```

## Development

### Testing Changes

```bash
# Run in dry-run mode to test without making changes
./shield-cleaner.sh -d -v

# Test specific features
./shield-cleaner.sh --pacman --dry-run
./shield-cleaner.sh --journal 25M -d
```

### Script Features

- **392 lines** of Bash code
- Color-coded output with icons
- Comprehensive error handling with `set -o pipefail`
- Size calculation and formatting utilities
- Interactive and automated modes
- Dry-run capability for safe testing

## Contributing

Contributions are welcome! Here's how you can help:

1. **Report Bugs**: Open an issue with detailed information
2. **Suggest Features**: Propose new cleaning operations or improvements
3. **Submit Pull Requests**: 
   - Fork the repository
   - Create a feature branch (`git checkout -b feature/amazing-feature`)
   - Test your changes with `make test`
   - Commit your changes (`git commit -m 'Add amazing feature'`)
   - Push to the branch (`git push origin feature/amazing-feature`)
   - Open a Pull Request

### Development Guidelines

- Follow existing code style and formatting
- Test all changes with dry-run mode first
- Update documentation for new features
- Ensure backward compatibility
- Add comments for complex logic

## Changelog

### Version 1.0.0 (Current)
- Initial release with 8 cleaning operations
- Interactive and automated modes
- Dry-run capability
- Color-coded output with progress tracking
- Comprehensive space usage reporting

## License

MIT License

## Author

Created with โค๏ธ for SHIELD systems

**Project maintained by:** Reyansh Raj Mishra  
**Repository:** https://github.com/reyanshrajmishra/shield-cleaner  
**AUR Package:** https://aur.archlinux.org/packages/shield-cleaner

---

**"You're in control."**
````