mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-26 06:31:04 +01:00
Solved systemctl bug and changed color fading algorythm
This commit is contained in:
parent
31dc0191f1
commit
cc19e3c5bf
@ -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_pull_primary_backups: "*-*-* 21:30:00"
|
||||||
on_calendar_renew_lets_encrypt_certificates: "*-*-* 12,00:30:00"
|
on_calendar_renew_lets_encrypt_certificates: "*-*-* 12,00:30:00"
|
||||||
on_calendar_deploy_mailu_certificates: "*-*-* 13,01: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
|
# Space Variables
|
||||||
size_percent_maximum_backup: 75
|
size_percent_maximum_backup: 75
|
||||||
|
@ -13,11 +13,11 @@ fi
|
|||||||
vendor_and_product_id=$1
|
vendor_and_product_id=$1
|
||||||
|
|
||||||
# Define the color transition parameters
|
# Define the color transition parameters
|
||||||
noon_color="ffffff"
|
|
||||||
twilight_color="ff00a8"
|
|
||||||
sunset_color="ff0000"
|
sunset_color="ff0000"
|
||||||
dawn_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
|
# Function to calculate the color based on the transition ratio
|
||||||
calculate_color() {
|
calculate_color() {
|
||||||
@ -25,12 +25,19 @@ calculate_color() {
|
|||||||
local color_end=$2
|
local color_end=$2
|
||||||
local transition_ratio=$3
|
local transition_ratio=$3
|
||||||
|
|
||||||
local start_value=$((16#${color_start}))
|
local start_r=$((16#${color_start:0:2}))
|
||||||
local end_value=$((16#${color_end}))
|
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
|
# 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_start="ff0000"
|
||||||
color_end="ff0000"
|
color_end="ff0000"
|
||||||
color_start_time="21:00"
|
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
|
elif [[ "$current_time" > "06:00" && "$current_time" < "09:00" ]]; then
|
||||||
# Transition from dawn to sunrise (06:00 to 09:00)
|
# Transition from dawn to sunrise (06:00 to 09:00)
|
||||||
color_start="ff0000"
|
color_start="ff0000"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
- name: Copy keyboard-color.timer file
|
- name: Copy keyboard-color.timer file
|
||||||
template:
|
template:
|
||||||
src: keyboard-color.timer.j2
|
src: keyboard-color.timer.j2
|
||||||
dest: /etc/systemd/system/keyboard-color.j2
|
dest: /etc/systemd/system/keyboard-color.timer
|
||||||
mode: 0644
|
mode: 0644
|
||||||
tags:
|
tags:
|
||||||
- keyboard-color
|
- keyboard-color
|
||||||
|
Loading…
Reference in New Issue
Block a user