Skip to content

Commit

Permalink
Update instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
basnijholt committed Sep 7, 2024
1 parent 25ec8d3 commit 3ac8e4e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 62 deletions.
90 changes: 42 additions & 48 deletions create-themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

import jinja2
import yaml
from PIL import Image
from PIL import ImageColor
from PIL import Image, ImageColor

with open("settings-light-dark.yaml", "r") as f:
with open("settings-light-dark.yaml") as f:
all_settings = yaml.safe_load(f)

COMMIT = "a37376d918fcfe4785be99910dc9a7200ac37da9"
Expand All @@ -30,12 +29,12 @@ def average_color(fname):
return "rgba({}, {}, {}, 0.4)".format(*rgb_color)


def fname_to_url(background: Path):
def fname_to_url(background: Path) -> str:
return f"{BASE_URL}/{background.name}"


def fname_to_local_path(folder: str, background: Path):
return f"/{folder}/themes/ios-themes/{background.name}"
def fname_to_local_path(background: Path) -> str:
return f"/local/ios-themes/{background.name}"


BACKGROUND_COLORS = {
Expand All @@ -49,45 +48,40 @@ def fname_to_local_path(folder: str, background: Path):
"red": "rgba(234, 88, 63, 0.4)",
}


folder_fname = [
("hacsfiles", Path("themes/ios-themes.yaml")),
("local", Path("manual-install/ios-themes.yaml")),
]
for folder, fname in folder_fname:
fname.parent.mkdir(parents=True, exist_ok=True)
with fname.open("w") as f:
f.write("---\n# From https://github.com/basnijholt/lovelace-ios-themes")
for background in sorted(Path("themes").glob("homekit-bg-*.jpg")):
color = background.stem.split("homekit-bg-")[-1]
if color in BACKGROUND_COLORS:
app_header_background_color = BACKGROUND_COLORS[color]
else:
app_header_background_color = average_color(background)
for which in ["light", "dark"]:
for standard in [False, True]:
settings = {k: parse(v[which]) for k, v in all_settings.items()}

if standard:
settings["state_icon_active_color"] = "rgba(255, 214, 10, 1)"
suffix = ""
else:
suffix = "-alternative"

with open("template.jinja2") as f:
template = jinja2.Template("".join(f.readlines()))

result = template.render(
**settings,
folder=folder,
which=which,
app_header_background_color=app_header_background_color,
background=fname_to_url(background)
if standard
else fname_to_local_path(folder, background),
color=color,
suffix=suffix,
)

with fname.open("a") as f:
f.write("\n" + result + "\n")
fname = Path("themes/ios-themes.yaml")
fname.parent.mkdir(parents=True, exist_ok=True)

with fname.open("w") as f:
f.write("---\n# From https://github.com/basnijholt/lovelace-ios-themes")
for background in sorted(Path("themes").glob("homekit-bg-*.jpg")):
color = background.stem.split("homekit-bg-")[-1]
if color in BACKGROUND_COLORS:
app_header_background_color = BACKGROUND_COLORS[color]
else:
app_header_background_color = average_color(background)
for which in ["light", "dark"]:
for standard in [False, True]:
settings = {k: parse(v[which]) for k, v in all_settings.items()}

if standard:
settings["state_icon_active_color"] = "rgba(255, 214, 10, 1)"
suffix = ""
else:
suffix = "-alternative"

with open("template.jinja2") as f:
template = jinja2.Template("".join(f.readlines()))

result = template.render(
**settings,
which=which,
app_header_background_color=app_header_background_color,
background=fname_to_url(background)
if standard
else fname_to_local_path(background),
color=color,
suffix=suffix,
)

with fname.open("a") as f:
f.write("\n" + result + "\n")
28 changes: 14 additions & 14 deletions themes/ios-themes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
ios-light-mode-blue-red-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-blue-red.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-blue-red.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9409" # from Apple systemOrange light mode
light-primary-color: "#2c2c2e" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -183,7 +183,7 @@ ios-light-mode-blue-red:
#
ios-dark-mode-blue-red-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-blue-red.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-blue-red.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9f09" # from Apple systemOrange dark mode
light-primary-color: "#B6B6C1" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -361,7 +361,7 @@ ios-dark-mode-blue-red:
#
ios-light-mode-dark-blue-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-dark-blue.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-dark-blue.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9409" # from Apple systemOrange light mode
light-primary-color: "#2c2c2e" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -539,7 +539,7 @@ ios-light-mode-dark-blue:
#
ios-dark-mode-dark-blue-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-dark-blue.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-dark-blue.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9f09" # from Apple systemOrange dark mode
light-primary-color: "#B6B6C1" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -717,7 +717,7 @@ ios-dark-mode-dark-blue:
#
ios-light-mode-dark-green-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-dark-green.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-dark-green.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9409" # from Apple systemOrange light mode
light-primary-color: "#2c2c2e" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -895,7 +895,7 @@ ios-light-mode-dark-green:
#
ios-dark-mode-dark-green-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-dark-green.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-dark-green.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9f09" # from Apple systemOrange dark mode
light-primary-color: "#B6B6C1" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -1073,7 +1073,7 @@ ios-dark-mode-dark-green:
#
ios-light-mode-light-blue-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-light-blue.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-light-blue.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9409" # from Apple systemOrange light mode
light-primary-color: "#2c2c2e" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -1251,7 +1251,7 @@ ios-light-mode-light-blue:
#
ios-dark-mode-light-blue-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-light-blue.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-light-blue.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9f09" # from Apple systemOrange dark mode
light-primary-color: "#B6B6C1" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -1429,7 +1429,7 @@ ios-dark-mode-light-blue:
#
ios-light-mode-light-green-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-light-green.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-light-green.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9409" # from Apple systemOrange light mode
light-primary-color: "#2c2c2e" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -1607,7 +1607,7 @@ ios-light-mode-light-green:
#
ios-dark-mode-light-green-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-light-green.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-light-green.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9f09" # from Apple systemOrange dark mode
light-primary-color: "#B6B6C1" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -1785,7 +1785,7 @@ ios-dark-mode-light-green:
#
ios-light-mode-orange-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-orange.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-orange.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9409" # from Apple systemOrange light mode
light-primary-color: "#2c2c2e" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -1963,7 +1963,7 @@ ios-light-mode-orange:
#
ios-dark-mode-orange-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-orange.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-orange.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9f09" # from Apple systemOrange dark mode
light-primary-color: "#B6B6C1" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -2141,7 +2141,7 @@ ios-dark-mode-orange:
#
ios-light-mode-red-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-red.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-red.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9409" # from Apple systemOrange light mode
light-primary-color: "#2c2c2e" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down Expand Up @@ -2319,7 +2319,7 @@ ios-light-mode-red:
#
ios-dark-mode-red-alternative:
# Global
background-image: "center / cover no-repeat fixed url('/hacsfiles/themes/ios-themes/homekit-bg-red.jpg')"
background-image: "center / cover no-repeat fixed url('/local/ios-themes/homekit-bg-red.jpg')"
lovelace-background: var(--background-image)
primary-color: "#ff9f09" # from Apple systemOrange dark mode
light-primary-color: "#B6B6C1" # (icons on left menu) (light: systemGray5 from iOS dark mode, dark: XXX)
Expand Down

0 comments on commit 3ac8e4e

Please sign in to comment.