From bac40d54c95b3f56b76d91a85ef61118a124d40d Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 16 Jun 2023 18:42:22 +0200 Subject: [PATCH] Optimized bug solution --- .../files/keyboard_color.sh | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/roles/pc_application-msi-keyboard-color/files/keyboard_color.sh b/roles/pc_application-msi-keyboard-color/files/keyboard_color.sh index cac5b3b6..d24a4b0f 100644 --- a/roles/pc_application-msi-keyboard-color/files/keyboard_color.sh +++ b/roles/pc_application-msi-keyboard-color/files/keyboard_color.sh @@ -42,18 +42,13 @@ calculate_color() { local current_g=$(awk "BEGIN { g = ${start_g} + (${end_g} - ${start_g}) * ${transition_ratio}; printf(\"%.0f\", g) }") local current_b=$(awk "BEGIN { b = ${start_b} + (${end_b} - ${start_b}) * ${transition_ratio}; printf(\"%.0f\", b) }") - # Set value to ff if value is 100 - if [ "$current_r" -eq 100 ]; then - current_r="ff" - fi - if [ "$current_g" -eq 100 ]; then - current_g="ff" - fi - if [ "$current_b" -eq 100 ]; then - current_b="ff" + local calculated_color=$(printf "%02x%02x%02x" "$current_r" "$current_g" "$current_b") + + if [ "$calculated_color" = "ffff100" ]; then + calculated_color="ffffff" fi - printf "%02x%02x%02x" "$current_r" "$current_g" "$current_b" + echo "$calculated_color" } # Get the current time in HH:MM format