Code Monkey home page Code Monkey logo

openhab-mdi's Introduction

openHAB Material Design Icons

This project creates a set of icons for use with openHAB 2 from the Material Design Icons (MDI).

Use

Type python3 mdi.py --help from the command line for more information.

The program uses as many defaults as possible, but any of those can be overwritten with a command line argument

$ python3 mdi.py --help
usage: mdi.py [-h] [-f FILE] [-i INPUT-PATH] [-o OUTPUT-PATH] [-n] [-q] [-e]

optional arguments:
  -h, --help            show this help message and exit
  -f FILE, --file FILE  get input/output mapping from FILE (default:
                        ./mdi.yaml)
  -i INPUT-PATH, --input-path INPUT-PATH
                        read icons from INPUT-PATH (default:
                        ./download/MaterialDesign-master/icons/svg)
  -o OUTPUT-PATH, --output-path OUTPUT-PATH
                        write icons to OUTPUT-PATH (default:
                        ./iconset)
  -n, --dry-run         parse yaml file for errors (default: False)
  -q, --quiet           don't print status messages to stdout (default: True)
  -e, --empty           empty output folder first (default: False)

Pre-requisites

Install the required libraries:

pip3 install -r requirements.txt

The script expects the source icons in the input folder. Download the repo as a ZIP and extract it there first.

Design

The icon set is built around default colors. A good overview of available colors can be found at W3 Schools.

The icon colors used are:

  • green: "#32CD32" (lime green)
  • orange: "#FF8C00" (dark orange)
  • yellow: "#FFD700" (gold)
  • red: "#DC143C" (crimson)
  • blue: "#0000CD" (medium blue)
  • grey: "#C0C0C0" (silver)

Skin colors (based on emoji):

  • skin type 1 and 2: "#FFDBB6"
  • skin type 3: "#ECBA8D"
  • skin type 4: "#CF8B5D"
  • skin type 5: "#AD5C2B"
  • skin type 6: "#614235"

Icon colors follow the dynamic state or value when possible. For example:

  • Switch ON = green
  • Switch OFF = red
  • Contact CLOSED = green
  • Contact OPEN = red

Gradients, for example for the dimmed light states, can be computed with tools like the color gradient table generator or RGB Color Gradient Maker.

Different sets

You can create your personal set of icons. This should preferably cover at least the classic icons, but can be extend to your personal preferences.

Minimal set

Any icon set should at least contain an icon for each channel category. A minimal set is included in the project as minimal.yaml.

Classic

openHAB currently includes an extended 'classic' set of icons. The classic set classic.yaml includes an alternative for any of these icons, including the minimal set. When you install the classic set, none of the original icons should be visible.

Extended (default)

An extended set of mapped icons. This includes the classic as well as a lot of extra usable icons. The set is available as mdi.yaml

Configuration

The script parses a YAML configuration file mdi.yaml. This file parses (a selected part of) the MDI library and creates a set of .svg icons from the source.

You can specify the source icon, the destination icon, the color of the destination icon and any alias for the icon. The color should be a valid HTML RGB code (e.g. #FF00FF).

Building the iconset

To build the iconset:

  1. Run python3 mdi.py from the command line to create the .svg icons in a subfolder iconset.
  2. Run the _icon_convert.sh script to create the corresponding .png files.

Using the iconset

That's easy. Just copy all files from the iconset folder to your openHAB configuration in the folder icons/classic.

TODO

  • Create intermediate folders for output. For now these need to be created manually before the script is run.

openhab-mdi's People

Contributors

jenserat avatar metbril avatar mueller-ma avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

openhab-mdi's Issues

Replace color codes with color scheme

The color scheme could be included with the icons yaml file, but this would be less flexible (to generate a personal flavor.

Other option is to have a separate config file per color scheme (.conf of .yaml) that is parsed during execution.

A third option is to set the colors through the command line. This is a lot of hassle, so the least favorable.

For now, I am thinking of option 2, a separate .conf (simple ini file type or json) configuration file type, that can be parsed as a command line parameter and defaults to mdi.conf.

Color Improvements

Hi,

I have a few suggestions:

  • Add background templates (circle, square, etc.) and a command line option, e.g. --background circle.svg
  • Add command line paramter to overwrite background and icon color. When you want to have colored backgrounds it might be a good idea to set all icons to black or white without the need to change .yaml files
  • After this is done we could try to add several material themes (black icons with no background, icons with circle background, etc.) to ESH or openHAB

Parent icons with dual skin tones

The classic iconset has icons for parent with dual skin tones. E.g. the man and woman have the same or different skin colors.

The script can only apply one color per icon and no gradient.

Drop support for different sets

Currently there are multiple config files for multiple sets. I personally don't see an advantage of having to maintain multiple files (e.g. changes I suggested in #5) over not generating all icons (Unused icons don't hurt the user, when he has them).

What do you think?

Wrong interpreter

The interpreter of mdi.py is #!/usr/local/bin/python3. You should change it to #!/usr/bin/env python3, so it works independently from how and where python is installed.

mdi fails with UnicodeDecodeError

The python script fails with a UnicodeDecodeError when reading the SVG files for some reason:

Copy /home/jenserat/src/openhab-mdi/download/MaterialDesign/icons/svg/playlist-play.svg to /home/jenserat/src/openhab-mdi/iconset/mdi/playlist.svg
Replace icon color with #000000
Traceback (most recent call last):
  File "./mdi.py", line 231, in <module>
    main(sys.argv)
  File "./mdi.py", line 209, in main
    svg_replace_fill(dstfile, '#000000', color)
  File "./mdi.py", line 21, in svg_replace_fill
    for line in file:
  File "/usr/lib/python3.5/fileinput.py", line 248, in __next__
    line = self._readline()
  File "/usr/lib/python3.5/fileinput.py", line 362, in _readline
    return self._readline()
  File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
FAIL: 1

I propose using ElementTree and XPath as a proper solution for manipulating SVG files (which are well-formed XML files and thus are better manipulated using XML-native libraries instead of running sed-like plain text editing anyway). I will propose a change that resolves this issue by replacing the whole function in a few minutes.

Support for missing icons

Some icons in the classic iconset are still missing in the MDI repo. During generation there are 2 options: use a stub icon that is used for any missing icon in the iconset or don't create an icon at all.

The current script supports this by defining icons (or not) in the yaml file. But perhaps we could add some configuration and a command line option to choose.

For example:

--missing help

for using the MDI help icon for any missing icon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.