Skip to content

Commit

Permalink
Add title option. Fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Aug 16, 2019
1 parent 432f9d6 commit 76f09fd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ favicon

[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/custom-components/hacs)

Change the favicon and app icons of your Home Assistant instance
Change the gui page title, favicon and app icons of your Home Assistant instance

![browser](https://user-images.githubusercontent.com/1299821/62975860-ad283a80-be1b-11e9-836a-d58a1732fb21.png)

Expand All @@ -21,6 +21,7 @@ Change the favicon and app icons of your Home Assistant instance

```yaml
favicon:
title: My Home
favicon: /local/favicons/favicon.ico
apple: /local/favicons/apple-touch-icon-180x180.png
32: /local/favicons/favicon-32x32.png
Expand All @@ -33,6 +34,8 @@ favicon:
# Options
- `title` - The title to display at the top of the window or browser tab.

- `favicon` - an .ico file which is displayed in your browser tab or bookmark menu.

- `apple` - a 180 x 180 px image that will be displayed on your iDevice home screen if you save the link there
Expand Down
3 changes: 3 additions & 0 deletions custom_components/favicon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ async def async_setup(hass, config):

favicon = config[DOMAIN].get('favicon')
apple = config[DOMAIN].get('apple')
title = config[DOMAIN].get('title')

if favicon or apple:
get_template = homeassistant.components.frontend.IndexView.get_template
Expand All @@ -24,6 +25,8 @@ def new_render(*args, **kwargs):
text = text.replace("/static/icons/favicon.ico", favicon)
if apple:
text = text.replace("/static/icons/favicon-apple-180x180.png", apple)
if title:
text = text.replace("<title>Home Assistant</title>", f"<title>{title}</title>")
return text
tpl.render = new_render
return tpl
Expand Down

0 comments on commit 76f09fd

Please sign in to comment.