diff --git a/group_vars/all b/group_vars/all index 58742922..cc7900bd 100644 --- a/group_vars/all +++ b/group_vars/all @@ -16,7 +16,7 @@ on_calendar_docker_compose_restart_unhealthy: "*-*-* 09,10,11,12,13,14,15,16,17, on_calendar_pull_primary_backups: "*-*-* 21:30:00" on_calendar_renew_lets_encrypt_certificates: "*-*-* 12,00:30:00" on_calendar_deploy_mailu_certificates: "*-*-* 13,01:30:00" -on_calendar_msi_keyboard_color: "*-*-* *:00,15,30,45:00" +on_calendar_msi_keyboard_color: "*-*-* *:*:00" # Space Variables size_percent_maximum_backup: 75 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 69a6581a..0971f8b0 100644 --- a/roles/pc_application-msi-keyboard-color/files/keyboard_color.sh +++ b/roles/pc_application-msi-keyboard-color/files/keyboard_color.sh @@ -13,11 +13,11 @@ fi vendor_and_product_id=$1 # Define the color transition parameters -noon_color="ffffff" -twilight_color="ff00a8" sunset_color="ff0000" dawn_color="ff0000" -sunrise_color="00e4ff" +sunrise_color="0000ff" +noon_color="ffffff" +twilight_color="ff00ff" # Function to calculate the color based on the transition ratio calculate_color() { @@ -25,12 +25,19 @@ calculate_color() { local color_end=$2 local transition_ratio=$3 - local start_value=$((16#${color_start})) - local end_value=$((16#${color_end})) + local start_r=$((16#${color_start:0:2})) + local start_g=$((16#${color_start:2:2})) + local start_b=$((16#${color_start:4:2})) - local current_value=$(awk "BEGIN { value = ${start_value} + (${end_value} - ${start_value}) * ${transition_ratio}; printf(\"%.0f\", value) }") + local end_r=$((16#${color_end:0:2})) + local end_g=$((16#${color_end:2:2})) + local end_b=$((16#${color_end:4:2})) - printf "%06x" "${current_value}" + local current_r=$(awk "BEGIN { r = ${start_r} + (${end_r} - ${start_r}) * ${transition_ratio}; printf(\"%.0f\", r) }") + 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) }") + + printf "%02x%02x%02x" "$current_r" "$current_g" "$current_b" } # Get the current time in HH:MM format @@ -42,7 +49,7 @@ if [[ "$current_time" > "21:00" || "$current_time" < "06:00" ]]; then color_start="ff0000" color_end="ff0000" color_start_time="21:00" - color_end_time="00:00" + color_end_time="06:00" elif [[ "$current_time" > "06:00" && "$current_time" < "09:00" ]]; then # Transition from dawn to sunrise (06:00 to 09:00) color_start="ff0000" @@ -88,4 +95,4 @@ current_color=$(calculate_color "$color_start" "$color_end" "$transition_ratio") echo "changing keyboard color to #$current_color." # Set the color using msi-perkeyrgb -msi-perkeyrgb --model GS65 -s "$current_color" --id "$vendor_and_product_id" \ No newline at end of file +msi-perkeyrgb --model GS65 -s "$current_color" --id "$vendor_and_product_id" diff --git a/roles/pc_application-msi-keyboard-color/tasks/setup_timers.yml b/roles/pc_application-msi-keyboard-color/tasks/setup_timers.yml index 5ec6c5e5..9db1d838 100644 --- a/roles/pc_application-msi-keyboard-color/tasks/setup_timers.yml +++ b/roles/pc_application-msi-keyboard-color/tasks/setup_timers.yml @@ -2,7 +2,7 @@ - name: Copy keyboard-color.timer file template: src: keyboard-color.timer.j2 - dest: /etc/systemd/system/keyboard-color.j2 + dest: /etc/systemd/system/keyboard-color.timer mode: 0644 tags: - keyboard-color