From ee84cf20247c261ece85c941db653749eebf6ed1 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 28 May 2023 09:34:39 +0200 Subject: [PATCH] Attempted to safe some bugs --- .../files/keyboard_color.sh | 17 +++++------------ .../tasks/setup_timers.yml | 4 ++-- .../templates/keyboard-color.service.j2 | 5 +---- 3 files changed, 8 insertions(+), 18 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 587bbdca..5ad825c5 100644 --- a/roles/pc_application-msi-keyboard-color/files/keyboard_color.sh +++ b/roles/pc_application-msi-keyboard-color/files/keyboard_color.sh @@ -38,12 +38,6 @@ else r=$(awk "BEGIN { value = 255 - 255 * $transition_ratio; printf(\"%.0f\", value) }") g=0 b=0 - - # Convert the RGB values to hexadecimal format - current_color=$(printf '%02x%02x%02x' $r $g $b) - - # Set the color using msi-perkeyrgb - sudo msi-perkeyrgb --model GS65 -s "$current_color" --id "$vendor_and_product_id" else # Calculate the transition ratio based on the time of day start_seconds=$(date -d "$transition_end" +%s) @@ -55,11 +49,10 @@ else r=$(awk "BEGIN { value = 255 * $transition_ratio; printf(\"%.0f\", value) }") g=$(awk "BEGIN { value = 0 + (255 - 0) * $transition_ratio; printf(\"%.0f\", value) }") b=$(awk "BEGIN { value = 0 + (255 - 0) * $transition_ratio; printf(\"%.0f\", value) }") - - # Convert the RGB values to hexadecimal format - current_color=$(printf '%02x%02x%02x' $r $g $b) - - # Set the color using msi-perkeyrgb - sudo msi-perkeyrgb --model GS65 -s "$current_color" --id "$vendor_and_product_id" fi + # Convert the RGB values to hexadecimal format + current_color=$(printf '%02x%02x%02x' $r $g $b) + + # Set the color using msi-perkeyrgb + msi-perkeyrgb --model GS65 -s "$current_color" --id "$vendor_and_product_id" fi 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 6b104fd4..5ec6c5e5 100644 --- a/roles/pc_application-msi-keyboard-color/tasks/setup_timers.yml +++ b/roles/pc_application-msi-keyboard-color/tasks/setup_timers.yml @@ -1,7 +1,7 @@ --- - name: Copy keyboard-color.timer file template: - src: keyboard-color.timer + src: keyboard-color.timer.j2 dest: /etc/systemd/system/keyboard-color.j2 mode: 0644 tags: @@ -24,7 +24,7 @@ - name: Enable and start keyboard-color.timer systemd: name: keyboard-color.timer - state: started + state: restarted enabled: yes tags: - keyboard-color diff --git a/roles/pc_application-msi-keyboard-color/templates/keyboard-color.service.j2 b/roles/pc_application-msi-keyboard-color/templates/keyboard-color.service.j2 index e2fcff03..8a6b62c0 100644 --- a/roles/pc_application-msi-keyboard-color/templates/keyboard-color.service.j2 +++ b/roles/pc_application-msi-keyboard-color/templates/keyboard-color.service.j2 @@ -3,7 +3,4 @@ Description=Keyboard Color Service [Service] Type=oneshot -ExecStart=/opt/keyboard_color.sh {{ vendor_and_product_id }} - -[Install] -WantedBy=default.target +ExecStart=/opt/keyboard_color.sh {{ vendor_and_product_id }} \ No newline at end of file