Add support for MDI icons (#3305)
2
.github/workflows/validate/Dockerfile
vendored
|
|
@ -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"]
|
||||||
|
|
|
||||||
46
.github/workflows/validate/validate.sh
vendored
|
|
@ -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
|
|
@ -1,4 +1,5 @@
|
||||||
build/*
|
build/*
|
||||||
|
mdi/*
|
||||||
|
|
||||||
# macOS Finder
|
# macOS Finder
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
|
||||||
|
Before Width: | Height: | Size: 15 KiB |
1
core_integrations/analytics/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:chart-timeline-variant
|
||||||
|
Before Width: | Height: | Size: 24 KiB |
|
Before Width: | Height: | Size: 6.9 KiB |
1
core_integrations/api/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:api
|
||||||
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
1
core_integrations/auth/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:shield-check
|
||||||
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
1
core_integrations/automation/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:robot
|
||||||
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 4.7 KiB |
1
core_integrations/camera/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:video
|
||||||
|
Before Width: | Height: | Size: 9.7 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
1
core_integrations/config/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:cog
|
||||||
|
Before Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
1
core_integrations/counter/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:counter
|
||||||
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
1
core_integrations/derivative/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:function-variant
|
||||||
|
Before Width: | Height: | Size: 7.8 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
1
core_integrations/group/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:google-circles-communities
|
||||||
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 6.4 KiB |
1
core_integrations/http/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:protocol
|
||||||
|
Before Width: | Height: | Size: 13 KiB |
|
|
@ -1 +0,0 @@
|
||||||
_homeassistant
|
|
||||||
1
core_integrations/image/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:image
|
||||||
|
Before Width: | Height: | Size: 6 KiB |
1
core_integrations/input_boolean/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:toggle-switch-outline
|
||||||
|
Before Width: | Height: | Size: 12 KiB |
|
|
@ -1 +0,0 @@
|
||||||
_homeassistant
|
|
||||||
1
core_integrations/input_button/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:gesture-tap-button
|
||||||
|
Before Width: | Height: | Size: 6.5 KiB |
1
core_integrations/input_datetime/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:clock
|
||||||
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 4.9 KiB |
1
core_integrations/input_number/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:ray-vertex
|
||||||
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
1
core_integrations/input_select/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:form-dropdown
|
||||||
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 5 KiB |
1
core_integrations/input_text/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:form-textbox
|
||||||
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 8.3 KiB |
1
core_integrations/integration/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:math-integral
|
||||||
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 4.5 KiB |
1
core_integrations/lovelace/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:view-dashboard
|
||||||
|
Before Width: | Height: | Size: 9.3 KiB |
|
Before Width: | Height: | Size: 6.2 KiB |
1
core_integrations/media_player/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:play-circle
|
||||||
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 10 KiB |
1
core_integrations/media_source/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:folder-multiple-image
|
||||||
|
Before Width: | Height: | Size: 30 KiB |
|
|
@ -1 +0,0 @@
|
||||||
_homeassistant
|
|
||||||
1
core_integrations/min_max/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:plus-minus-variant
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
_homeassistant
|
|
||||||
1
core_integrations/moon/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:moon-waning-crescent
|
||||||
|
Before Width: | Height: | Size: 4.9 KiB |
1
core_integrations/notify/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:message-alert
|
||||||
|
Before Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
1
core_integrations/onboarding/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:card-account-details
|
||||||
|
Before Width: | Height: | Size: 11 KiB |
|
|
@ -1 +0,0 @@
|
||||||
_homeassistant
|
|
||||||
1
core_integrations/persistent_notification/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:bell
|
||||||
|
Before Width: | Height: | Size: 5.7 KiB |
1
core_integrations/person/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:account
|
||||||
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 5.3 KiB |
1
core_integrations/script/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:script-text
|
||||||
|
Before Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 6.4 KiB |
1
core_integrations/search/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:magnify
|
||||||
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 6.5 KiB |
1
core_integrations/sensor/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:eye
|
||||||
|
Before Width: | Height: | Size: 14 KiB |
|
|
@ -1 +0,0 @@
|
||||||
switch
|
|
||||||
1
core_integrations/switch_as_x/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:swap-horizontal
|
||||||
|
Before Width: | Height: | Size: 5.5 KiB |
1
core_integrations/system_log/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:format-list-bulleted-type
|
||||||
|
Before Width: | Height: | Size: 11 KiB |
|
|
@ -1 +0,0 @@
|
||||||
_homeassistant
|
|
||||||
1
core_integrations/threshold/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:chart-sankey
|
||||||
|
Before Width: | Height: | Size: 5.9 KiB |
1
core_integrations/timer/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:timer
|
||||||
|
Before Width: | Height: | Size: 12 KiB |
|
|
@ -1 +0,0 @@
|
||||||
_homeassistant
|
|
||||||
1
core_integrations/tod/icon.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
mdi:hours-24
|
||||||