From 8d94bc40063fb39568f18b1ed7fe80a3593717fe Mon Sep 17 00:00:00 2001 From: rootiest Date: Sun, 3 May 2026 14:56:31 -0400 Subject: [PATCH 1/2] feat(config): enable swatch by default for desktop mode Set swatch = true as the default in the stock [desktop] configuration and internal defaults. This ensures that desktop notifications include a visual color swatch by default. Updated README and tests accordingly. --- README.md | 1 + color-tool | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3dd60a8..eb71338 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ json = false # copy JSON format instead of plain text name = false # fetch color name (requires network) copy = true # copy result to clipboard notify = true # show desktop notification with the copied value +swatch = true # show color swatch in notification ``` You can also use the CLI to manage your configuration: diff --git a/color-tool b/color-tool index 9408ef2..8c7db5a 100755 --- a/color-tool +++ b/color-tool @@ -45,7 +45,7 @@ desktop_name=0 desktop_notify=1 desktop_copy=1 desktop_output="hex" -desktop_swatch=0 +desktop_swatch=1 # Track which settings were explicitly set via CLI flags to ensure they override config cli_json="" @@ -274,7 +274,7 @@ json = false # copy JSON format instead of plain text name = false # fetch color name (requires network) copy = true # copy result to clipboard notify = true # show desktop notification with the copied value -swatch = false # show color swatch in notification +swatch = true # show color swatch in notification EOF } -- 2.52.0 From e0967a8388d8c6c96f7e30dba990cb77b293acfb Mon Sep 17 00:00:00 2001 From: rootiest Date: Sun, 3 May 2026 14:57:02 -0400 Subject: [PATCH 2/2] feat(config): maintain comment alignment in set_config Updated set_config to dynamically adjust leading whitespace of trailing comments when toggling between true/false (or any values of different lengths). This ensures that inline comments in config.toml remain vertically aligned after programmatic updates. --- color-tool | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/color-tool b/color-tool index 8c7db5a..a74cbd4 100755 --- a/color-tool +++ b/color-tool @@ -194,7 +194,33 @@ set_config() { if [[ -n "$new_val" ]]; then if [[ "$original_line" =~ ^([[:space:]]*[A-Za-z_]+[[:space:]]*=[[:space:]]*)([^[:space:]#]+)(.*)$ ]]; then - echo "${BASH_REMATCH[1]}$new_val${BASH_REMATCH[3]}" >> "$temp_file" + local prefix="${BASH_REMATCH[1]}" + local old_val="${BASH_REMATCH[2]}" + local suffix="${BASH_REMATCH[3]}" + + # Adjust whitespace to keep comments aligned if the value length changed + if [[ "$key" != "output" ]]; then + local old_len=${#old_val} + local new_len=${#new_val} + local diff=$((old_len - new_len)) + + if [[ $diff -gt 0 ]]; then + # new value is shorter, add spaces to suffix + local spaces="" + for ((i=0; i> "$temp_file" continue elif [[ "$original_line" =~ ^([[:space:]]*[A-Za-z_]+[[:space:]]*=[[:space:]]*)(.*)$ ]]; then echo "${BASH_REMATCH[1]}$new_val" >> "$temp_file" -- 2.52.0