Add support for MDI icons (#3305)

This commit is contained in:
Franck Nijhof 2022-04-01 20:16:04 +02:00 committed by GitHub
parent 81ce2933e5
commit b6aa47659a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
118 changed files with 118 additions and 20 deletions

View file

@ -1,4 +1,4 @@
FROM alpine FROM alpine
RUN apk add --no-cache imagemagick bash RUN apk add --no-cache imagemagick bash git optipng
COPY validate.sh /validate.sh COPY validate.sh /validate.sh
ENTRYPOINT ["/validate.sh"] ENTRYPOINT ["/validate.sh"]

View file

@ -17,22 +17,15 @@ function error() {
fi fi
} }
# Clone MDI icons
rm -f -r mdi
git clone --depth=1 https://github.com/Templarian/MaterialDesign mdi
# Find all files in the src folder (should contain only images) # Find all files in the src folder (should contain only images)
while read image; do while read image; do
# Read properties from image
properties=($(identify -format "%w %h %m" "${image}"))
if [[ "$?" -ne 0 ]]; then
error "${image}" "Could not read image file"
continue
fi
# Extract properties into variables
filename=$(basename "${image}") filename=$(basename "${image}")
folderpath=$(dirname "${image}") folderpath=$(dirname "${image}")
foldername=$(basename "${folderpath}") foldername=$(basename "${folderpath}")
width="${properties[0]}"
height="${properties[1]}"
type="${properties[2]}"
# Underscore folders are special cases. Instead one should symlink between integration domains # Underscore folders are special cases. Instead one should symlink between integration domains
[[ "${foldername}" == _* && "${foldername}" != "_placeholder" && "${foldername}" != "_homeassistant" ]] \ [[ "${foldername}" == _* && "${foldername}" != "_placeholder" && "${foldername}" != "_homeassistant" ]] \
@ -43,6 +36,37 @@ while read image; do
&& [[ -d "custom_integrations/${foldername}" ]] \ && [[ -d "custom_integrations/${foldername}" ]] \
&& error "${folderpath}" "The integration ${foldername} exists in both core and custom integrations. Core wins." && error "${folderpath}" "The integration ${foldername} exists in both core and custom integrations. Core wins."
# If icon filename is icon.txt
if [[ "${filename}" == "icon.txt" ]]; then
mdi=$(<${image})
mdi="${mdi##mdi:}"
# Check if the icon exists
[[ -f "mdi/svg/${mdi}.svg" ]] \
|| error "${image}" "The icon 'mdi:${mdi}' does not exist"
# Ensure icon.png and icon@2x.png are missing
[[ -f "${folderpath}/icon.png" ]] \
&& error "${image}" "icon.png exists while icon.txt was provided"
[[ -f "${folderpath}/icon@2x.png" ]] \
&& error "${image}" "icon@2x.png exists while icon.txt was provided"
# Continue to next image
continue
fi
# Read properties from image
properties=($(identify -format "%w %h %m" "${image}"))
if [[ "$?" -ne 0 ]]; then
error "${image}" "Could not read image file"
continue
fi
# Extract properties into variables
width="${properties[0]}"
height="${properties[1]}"
type="${properties[2]}"
# Ensure file is actually a PNG file # Ensure file is actually a PNG file
[[ "${type}" != "PNG" ]] \ [[ "${type}" != "PNG" ]] \
&& error "${image}" "Invalid file type '${type}' for file" && error "${image}" "Invalid file type '${type}' for file"

1
.gitignore vendored
View file

@ -1,4 +1,5 @@
build/* build/*
mdi/*
# macOS Finder # macOS Finder
.DS_Store .DS_Store

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

View file

@ -0,0 +1 @@
mdi:chart-timeline-variant

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

View file

@ -0,0 +1 @@
mdi:api

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

View file

@ -0,0 +1 @@
mdi:shield-check

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

View file

@ -0,0 +1 @@
mdi:robot

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

View file

@ -0,0 +1 @@
mdi:video

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -0,0 +1 @@
mdi:cog

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -0,0 +1 @@
mdi:counter

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -0,0 +1 @@
mdi:function-variant

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

View file

@ -0,0 +1 @@
mdi:google-circles-communities

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

View file

@ -0,0 +1 @@
mdi:protocol

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

View file

@ -1 +0,0 @@
_homeassistant

View file

@ -0,0 +1 @@
mdi:image

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6 KiB

View file

@ -0,0 +1 @@
mdi:toggle-switch-outline

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View file

@ -1 +0,0 @@
_homeassistant

View file

@ -0,0 +1 @@
mdi:gesture-tap-button

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -0,0 +1 @@
mdi:clock

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -0,0 +1 @@
mdi:ray-vertex

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -0,0 +1 @@
mdi:form-dropdown

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5 KiB

View file

@ -0,0 +1 @@
mdi:form-textbox

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.3 KiB

View file

@ -0,0 +1 @@
mdi:math-integral

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

View file

@ -0,0 +1 @@
mdi:view-dashboard

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

View file

@ -0,0 +1 @@
mdi:play-circle

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

View file

@ -0,0 +1 @@
mdi:folder-multiple-image

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

View file

@ -1 +0,0 @@
_homeassistant

View file

@ -0,0 +1 @@
mdi:plus-minus-variant

View file

@ -1 +0,0 @@
_homeassistant

View file

@ -0,0 +1 @@
mdi:moon-waning-crescent

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -0,0 +1 @@
mdi:message-alert

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -0,0 +1 @@
mdi:card-account-details

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View file

@ -1 +0,0 @@
_homeassistant

View file

@ -0,0 +1 @@
mdi:bell

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

View file

@ -0,0 +1 @@
mdi:account

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -0,0 +1 @@
mdi:script-text

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

View file

@ -0,0 +1 @@
mdi:magnify

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -0,0 +1 @@
mdi:eye

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View file

@ -1 +0,0 @@
switch

View file

@ -0,0 +1 @@
mdi:swap-horizontal

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -0,0 +1 @@
mdi:format-list-bulleted-type

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

View file

@ -1 +0,0 @@
_homeassistant

View file

@ -0,0 +1 @@
mdi:chart-sankey

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -0,0 +1 @@
mdi:timer

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View file

@ -1 +0,0 @@
_homeassistant

View file

@ -0,0 +1 @@
mdi:hours-24

Some files were not shown because too many files have changed in this diff Show more