From 61c45bd767ea67e42aaab555abfbf5884803df99 Mon Sep 17 00:00:00 2001 From: tittu Date: Mon, 29 Jun 2026 22:09:39 +0530 Subject: [PATCH] accept percentage as hex alpha --- README.md | 5 ++--- src/colors.rs | 12 ++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index eac7a32..009b38a 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,6 @@ Wallbash is a **single binary** that can run in two modes: - **Daemon Mode:** Run `wallbash start` to explicitly launch the daemon, or let it be started automatically on first use. The daemon: - Manages the Wayland surface and Vulkan rendering pipeline. - Listens for commands via a Unix socket (`/tmp/wallbash.sock`). - - Handles wallpaper transitions, animations, and multi‑monitor setups. - Persists in the background until stopped with `wallbash stop`. The core **modules** are structured as: @@ -69,13 +68,13 @@ The core **modules** are structured as: - **wayland.rs** Handles the Wayland connection. Creates and manages the surface, sets up the output, and handles window events. This is the interface between wallbash and your Wayland compositor. - **vulkan.rs** Handles the GPU initialization, texture creation, shader compilation, and draws the wallpaper surface using Vulkan. This provides the image rendering pipeline. - **filters.rs** Applies Vulkan compute shaders which currently implements a blur effect for the background. The module is designed to be extensible for additional filters in future. -- **colors.rs** Extracts the dominant color from the wallpaper using k-means clustering, converts colors and generates a full Material Design color palette. Its then deployed to your config files using built-in template system. +- **colors.rs** Extracts the dominant color from the wallpaper using k-means clustering, converts colors and generates a color palette. It's then deployed to your config files based on templates. ## Theming Wallbash generates a color palette from your wallpaper. You can use these colors to dynamically theme your entire desktop environment. -For detailed guides, usage, and application specific examples, check out the [wiki](https://github.com/prasanthrangan/wallbash/wiki) *(work in progress)*. +For detailed guides, usage, and application specific examples, check out the [wiki](https://github.com/prasanthrangan/wallbash/wiki/Theming). ###### *
// HyDE
*

diff --git a/src/colors.rs b/src/colors.rs index 1d3b7aa..f4a1285 100644 --- a/src/colors.rs +++ b/src/colors.rs @@ -493,11 +493,15 @@ fn parse_alpha(s: &str) -> Option { if s.is_empty() { return None } if s.contains('.') { let val = s.parse::().ok()?; - Some(ColorFormat::Rgba(val.clamp(0.0, 1.0))) - } else { - let val = u8::from_str_radix(s, 16).ok()?; - Some(ColorFormat::Hex(val)) + return Some(ColorFormat::Rgba(val.clamp(0.0, 1.0))); + } + if let Ok(pct) = s.parse::() { + if (1..=100).contains(&pct) { + let val = ((pct as f64 / 100.0) * 255.0).round() as u8; + return Some(ColorFormat::Hex(val)); + } } + None } fn scan_templates(root: &std::path::Path) -> Vec {