feat: add dependency check and refactor global state
- Implement check_deps function and --check-deps flag for environment validation. - Add truecolor support detection for terminal swatches. - Colorize --install output and stylized logo. - Refactor script to use global constants for colors and paths. - Improve installation logic with robust directory creation. - Update README.md and --help with new flag and detailed prerequisites.
This commit is contained in:
@@ -16,30 +16,56 @@ A feature-rich, portable CLI color utility for Linux, specializing in color pick
|
||||
|
||||
## 📋 Prerequisites
|
||||
|
||||
To utilize all features, ensure the following are installed:
|
||||
- **KDE Plasma + Wayland:** Required for the `--pick` functionality.
|
||||
- **Python 3 + PyQt6:** Required for the picker helper.
|
||||
- **curl + jq:** Required for color naming support.
|
||||
- **wl-clipboard** (Wayland) or **xclip** (X11): Required for clipboard support.
|
||||
- **libnotify:** Required for desktop notifications (`notify-send`).
|
||||
- **ImageMagick (`magick` or `convert`):** Required for generating visual color swatches in desktop notifications.
|
||||
### Required Core Dependencies
|
||||
These are mandatory for the script to run and perform basic color conversions:
|
||||
- **Python 3:** Handles all color space math and conversions.
|
||||
- **jq:** Powers JSON formatting and internal data parsing.
|
||||
|
||||
### Optional Feature Dependencies
|
||||
These enable specific functionality and can be installed as needed:
|
||||
- **KDE Plasma (Wayland):** Required for screen color picking (`--pick`).
|
||||
- **Python 3 PyQt6:** Required for the KDE color picker DBus interface.
|
||||
- **wl-clipboard** or **xclip:** Enables copying results to the system clipboard (`--copy`).
|
||||
- **curl:** Required for fetching human-readable color names from the web (`--name`).
|
||||
- **libnotify:** Enables desktop notifications (`--notify`).
|
||||
- **ImageMagick:** Generates visual color swatch icons for notifications (`--swatch`).
|
||||
- **Truecolor Terminal Emulator:** Required for accurate visual swatches in terminal output (`--swatch`).
|
||||
|
||||
> **Tip:** Use `color-tool --check-deps` to quickly see which dependencies are currently met on your system.
|
||||
|
||||
## 🚀 Installation
|
||||
|
||||
### Automatic Installation (Recommended)
|
||||
|
||||
You can download the script directly from the [latest release](https://git.rootiest.dev/rootiest/color-tool/releases/latest) and install it:
|
||||
|
||||
```bash
|
||||
curl -sSLO https://git.rootiest.dev/rootiest/color-tool/releases/download/latest/color-tool
|
||||
chmod +x color-tool
|
||||
./color-tool --install
|
||||
# Download and install the latest version of the color-tool script
|
||||
curl -sSLO https://git.rootiest.dev/rootiest/color-tool/releases/download/latest/color-tool && bash color-tool --install && rm ./color-tool
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Move the script to `~/.local/share/color-tool/`.
|
||||
1. Install the script to `~/.local/share/color-tool/`.
|
||||
2. Symlink the binary to `~/.local/bin/color-tool`.
|
||||
3. Generate a sample configuration at `~/.config/color-tool/config.toml`.
|
||||
4. Create a `.desktop` entry so you can launch the picker from your application menu.
|
||||
5. Verify and warn about any missing optional or required system dependencies.
|
||||
6. Clean up the downloaded script after installation.
|
||||
|
||||
### Manual Usage
|
||||
|
||||
Alternatively, you can [download the script](https://git.rootiest.dev/rootiest/color-tool/releases/latest) manually.
|
||||
Then run it from any location without installation:
|
||||
|
||||
```bash
|
||||
# Make script executable
|
||||
chmod +x color-tool
|
||||
# Run script directly
|
||||
./color-tool --pick --output hex,rgb
|
||||
```
|
||||
|
||||
However, this will not add the script to your `$PATH` or create a desktop entry,
|
||||
so you won't be able to launch it from the app menu or use it globally without specifying the path.
|
||||
|
||||
## 🛠 Usage
|
||||
|
||||
@@ -58,6 +84,7 @@ Options:
|
||||
--get-config Print the current configuration
|
||||
--set-config Update the configuration (e.g. --set-config desktop --copy)
|
||||
--reset-config Restore the configuration file to its default values
|
||||
--check-deps Check system dependencies and environment support
|
||||
--install Install to ~/.local/share/ and symlink to ~/.local/bin/
|
||||
--help, -h Show this help message
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user