Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config icon #6

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions devdeck_key_light/key_light_toggle_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@
import os
import requests

from xdg.BaseDirectory import *

from devdeck_core.controls.deck_control import DeckControl

defaultIconPath = os.path.join(xdg_config_dirs[0], 'devdeck/assets')

class KeyLightToggleControl(DeckControl):
def __init__(self, key_no, **kwargs):
self.elgato = None
self.__logger = logging.getLogger('devdeck')
super().__init__(key_no, **kwargs)

self.iconPath = self.settings['iconPath'] or defaultIconPath

def initialize(self):
self.__render_icon()
Expand Down Expand Up @@ -42,10 +47,10 @@ def __render_icon(self):
with self.deck_context() as context:
if data['lights'][0]['on'] == 1:
with context.renderer() as r:
r.image(os.path.join(os.path.dirname(__file__), "assets", 'key-light-on.png')).end()
r.image(os.path.join(self.iconPath, self.settings['lightOnIcon'])).end()
else:
with context.renderer() as r:
r.image(os.path.join(os.path.dirname(__file__), "assets", 'key-light-off.png')).end()
r.image(os.path.join(self.iconPath, self.settings['lightOffIcon'])).end()
except requests.exceptions.ConnectionError as ex:
self.__logger.warning("Error communicating with Elgato Key Light: %s", str(ex))
with self.deck_context() as context:
Expand All @@ -59,3 +64,22 @@ def __render_icon(self):
.text_align('center') \
.end()

def settings_schema(self):
return {
'host': {
'type': 'string',
'required': True
}
'lightOnIcon': {
'type': 'string',
'required': True
}
'ligtOffIcon': {
'type': 'string',
'required': True
}
'iconPath': {
'type': 'string',
'required': False
}
}
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ assertpy==1.1
devdeck-core==1.0.7
pytest==6.2.1
requests==2.25.1
vcrpy==4.1.1
vcrpy==4.1.1
pyxdg