From 98fe49368bb90087e0c7f67f01fc0a5d6f4e026f Mon Sep 17 00:00:00 2001 From: Uyanide Date: Sat, 18 Oct 2025 18:22:22 +0200 Subject: [PATCH] script: fix 'apply-color's --- .kvantum/apply-color | 2 +- .utils/apply-color-parse-arg | 12 ++++++- eww/apply-color | 2 +- fastfetch/apply-color | 13 +++++++ fish/apply-color | 56 ++++++++++++++++++++++++------- fuzzel/apply-color | 2 +- hypr/apply-color | 2 +- mako/apply-color | 2 +- niri/apply-color | 2 +- niri/config.kdl | 17 +++++++++- posh_theme.omp.json | 8 ++--- quickshell/Services/IpService.qml | 14 ++------ quickshell/apply-color | 2 +- rofi/apply-color | 2 +- waybar/apply-color | 2 +- wlogout-niri/apply-color | 2 +- wlogout/apply-color | 2 +- yazi/apply-color | 2 +- 18 files changed, 103 insertions(+), 41 deletions(-) create mode 100755 fastfetch/apply-color diff --git a/.kvantum/apply-color b/.kvantum/apply-color index fa750b3..413d4bf 100755 --- a/.kvantum/apply-color +++ b/.kvantum/apply-color @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash path=$(dirname "$(readlink -f "$0")") . "$path"/../.utils/apply-color-parse-arg diff --git a/.utils/apply-color-parse-arg b/.utils/apply-color-parse-arg index f3eb458..ffd7be4 100644 --- a/.utils/apply-color-parse-arg +++ b/.utils/apply-color-parse-arg @@ -15,6 +15,16 @@ function log_info { printf "\033[0;32mInfo:\033[0m $1\n" >&2 } +function color_ansi { + colorHex="$1" + + local r=$((16#${colorHex:0:2})) + local g=$((16#${colorHex:2:2})) + local b=$((16#${colorHex:4:2})) + + echo "\033[38;2;${r};${g};${b}m" +} + # remove leading '#' if present if [[ $colorHex == \#* ]]; then @@ -28,5 +38,5 @@ if ! [[ $colorHex =~ ^[0-9A-Fa-f]{6}$ ]]; then fi function log_success { - log_info "Applied primary color ${colorName} (${colorHex}) to \033[1;34m$1\033[0m" + log_info "Applied palette \033[1;34m${palette}\033[0m with primary color $(color_ansi $colorHex)${colorName} (#${colorHex})\033[0m to \033[1;34m$1\033[0m" } \ No newline at end of file diff --git a/eww/apply-color b/eww/apply-color index 60fe91d..7ea6522 100755 --- a/eww/apply-color +++ b/eww/apply-color @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash path=$(dirname "$(readlink -f "$0")") . "$path"/../.utils/apply-color-parse-arg diff --git a/fastfetch/apply-color b/fastfetch/apply-color new file mode 100755 index 0000000..7f4f928 --- /dev/null +++ b/fastfetch/apply-color @@ -0,0 +1,13 @@ +#!/bin/bash + +path=$(dirname "$(readlink -f "$0")") +. "$path"/../.utils/apply-color-parse-arg + +file="$path"/../fish/post.d/fetch.fish + +sed -i -E "s/(set -g fetch_color\s+\"#)([0-9a-fA-F]{6})(\")/\1${colorHex}\3/" "$file" || { + log_error "Failed to edit ${file}" + exit 1 +} + +log_success "fastfetch" \ No newline at end of file diff --git a/fish/apply-color b/fish/apply-color index 1d84052..90113df 100755 --- a/fish/apply-color +++ b/fish/apply-color @@ -1,24 +1,56 @@ -#!/bin/sh +#!/bin/bash path=$(dirname "$(readlink -f "$0")") . "$path"/../.utils/apply-color-parse-arg -file="$path"/post.d/fetch.fish - -sed -i 's/^\( set -g fetch_color "\)#\([0-9a-fA-F]\{6\}\)"/\1#'"${colorHex}"'"/' "$file" || { - log_error "Failed to edit ${file}" - exit 1 -} - -log_success "fastfetch" - # Also apply to omp here file="$path"/../posh_theme.omp.json -sed -i 's/\("foreground":[[:space:]]*"\)#\([0-9a-fA-F]\{6\}\)"/\1#'"${colorHex}"'"/g' "$file" || { +targetTypes='["os", "session", "status"]' + +python3 <