Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b58cc8a13 | |||
|
e0967a8388
|
|||
|
8d94bc4006
|
|||
| 10014d5ee9 | |||
|
8333d249d9
|
@@ -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:
|
||||
|
||||
+30
-4
@@ -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=""
|
||||
@@ -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<diff; i++)); do spaces+=" "; done
|
||||
suffix="$spaces$suffix"
|
||||
elif [[ $diff -lt 0 ]]; then
|
||||
# new value is longer, remove spaces from suffix
|
||||
local remove=$((-diff))
|
||||
for ((i=0; i<remove; i++)); do
|
||||
if [[ "$suffix" == " "* ]]; then
|
||||
suffix="${suffix# }"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$prefix$new_val$suffix" >> "$temp_file"
|
||||
continue
|
||||
elif [[ "$original_line" =~ ^([[:space:]]*[A-Za-z_]+[[:space:]]*=[[:space:]]*)(.*)$ ]]; then
|
||||
echo "${BASH_REMATCH[1]}$new_val" >> "$temp_file"
|
||||
@@ -274,7 +300,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
|
||||
}
|
||||
|
||||
@@ -305,7 +331,7 @@ show_help() {
|
||||
printf " ${bold}${cyan}--output${reset} ${dim}FMT${reset} Format(s) to output: ${cyan}hex, rgb, hsl, rgba, hsla, hexa, all${reset} ${dim}(comma-separated)${reset}\n"
|
||||
printf " ${bold}${cyan}--[no-]json${reset} Output as a JSON table of selected formats\n"
|
||||
printf " ${bold}${cyan}--[no-]name${reset} Fetch nearest color name from thecolorapi.com ${dim}(requires curl, jq)${reset}\n"
|
||||
printf " ${bold}${cyan}--[no-]swatch${reset} Include a color swatch in the terminal output\n"
|
||||
printf " ${bold}${cyan}--[no-]swatch${reset} Include a color swatch in the terminal output and desktop notification\n"
|
||||
printf " ${bold}${cyan}--[no-]copy${reset} Copy result to clipboard ${dim}(wl-clipboard preferred, xclip as fallback)${reset}\n"
|
||||
printf " ${bold}${cyan}--[no-]notify${reset} Show desktop notification ${dim}(on by default in --desktop)${reset}\n"
|
||||
printf " ${bold}${cyan}--desktop${reset} GUI mode: pick → copy → notify ${dim}(for app menu / .desktop launcher)${reset}\n"
|
||||
|
||||
Reference in New Issue
Block a user