├── .drone.yml ├── .gitignore ├── README.md ├── SampleI3.jpg ├── doc ├── Makefile ├── make.bat └── source │ ├── conf.py │ └── index.rst ├── src ├── Assets │ ├── Emoji Icon License.txt │ ├── Exit.png │ ├── Font Awesome 5 Free-Solid-900.otf │ ├── Gradient Icons License.txt │ ├── Pressed.png │ ├── Released.png │ ├── Roboto License.txt │ ├── Roboto Mono for Powerline.ttf │ ├── Roboto-Regular.ttf │ └── i3_logo.png ├── I3 │ └── I3Helper.py ├── Icon │ └── IconHelper.py ├── StreamDeck │ ├── StreamDeck.py │ └── Transport │ │ └── HIDAPI.py ├── config.json └── start.py └── start.sh /.drone.yml: -------------------------------------------------------------------------------- 1 | kind: pipeline 2 | name: Build Tests 3 | 4 | platform: 5 | os: linux 6 | arch: amd64 7 | 8 | steps: 9 | - name: Flake8 10 | image: abcminiuser/docker-ci-python:latest 11 | pull: always 12 | commands: 13 | - flake8 --ignore E501 src/ 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | doc/build 3 | .idea 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Elgato Stream Deck with i3 wm 2 | 3 | > Work in progress 4 | 5 | Control your i3 window manager with an [Elgato Stream Deck](https://www.elgato.com/en/gaming/stream-deck). Switch between workspaces, which are previewed directly on your stream deck. 6 | Based on the [Python Elgato Stream Deck Library](https://github.com/abcminiuser/python-elgato-streamdeck) 7 | 8 | ![Example](SampleI3.jpg) 9 | 10 | #### Dependencies 11 | 12 | * i3ipc 13 | * mss 14 | * Pillow (or any compatible fork) 15 | 16 | #### Running 17 | 18 | > Make sure you follow the Installation Guide of the Python Elgato Stream Deck Library below 19 | 20 | ```bash 21 | ./start.sh 22 | ``` 23 | 24 | #### Python Elgato Stream Deck Library 25 | 26 | This is an open source Python 3 library to control an 27 | [Elgato Stream Deck](https://www.elgato.com/en/gaming/stream-deck) directly, 28 | without the official software. This can allow you to create your own custom 29 | front-ends, such as a custom control front-end for home automation software. 30 | 31 | ## Credits: 32 | 33 | I've used the reverse engineering notes from 34 | [this GitHub](https://github.com/Lange/node-elgato-stream-deck/blob/master/NOTES.md) 35 | repository to implement this library. Thanks Alex Van Camp! 36 | 37 | ## Status: 38 | 39 | Working - you can enumerate devices, set the brightness of the panel(s), set 40 | the images shown on each button, and read the current button states. 41 | 42 | ## Dependencies: 43 | 44 | The library core has no special dependencies, but does use one of (potentially) 45 | several HID backend libraries. You will need to install the dependencies 46 | appropriate to your chosen backend. 47 | 48 | The included example requires the PIL fork "Pillow", although it can be swapped 49 | out if desired for any other image library as desired by the user application. 50 | 51 | ### HIDAPI Backend 52 | The default backend is the HIDAPI Python library, which should work across 53 | the three major (Windows, Mac, Linux) OSes. 54 | 55 | Installation: 56 | ``` 57 | pip3 install hidapi 58 | ``` 59 | 60 | ## Raspberry Pi Installation: 61 | 62 | The following script has been verified working on a Raspberry Pi (Model 2 B) 63 | running a stock Debian Stretch image, to install all the required dependencies 64 | needed by this project: 65 | 66 | ``` 67 | # Ensure system is up to date, upgrade all out of date packages 68 | sudo apt update && sudo apt dist-upgrade -y 69 | 70 | # Install the pip Python package manager 71 | sudo apt install -y python3-pip 72 | 73 | # Install system packages needed for the Python hidapi package installation 74 | sudo apt install -y libudev-dev libusb-1.0-0-dev 75 | 76 | # Install dependencies 77 | pip3 install hidapi 78 | 79 | # Add udev rule to allow all users non-root access to Elgato StreamDeck devices: 80 | sudo tee /etc/udev/rules.d/10-streamdeck.rules << EOF 81 | SUBSYSTEMS=="usb", ATTRS{idVendor}=="0fd9", ATTRS{idProduct}=="0060", GROUP="users" 82 | EOF 83 | 84 | # Install git and check out the repository 85 | sudo apt install -y git 86 | git clone https://github.com/abcminiuser/python-elgato-streamdeck.git 87 | ``` 88 | 89 | Note that after adding the `udev` rule, a restart will be required in order for 90 | it to take effect and allow access to the StreamDeck device without requiring 91 | root privileges. 92 | 93 | ## License: 94 | 95 | Released under the MIT license: 96 | 97 | ``` 98 | Permission to use, copy, modify, and distribute this software 99 | and its documentation for any purpose is hereby granted without 100 | fee, provided that the above copyright notice appear in all 101 | copies and that both that the copyright notice and this 102 | permission notice and warranty disclaimer appear in supporting 103 | documentation, and that the name of the author not be used in 104 | advertising or publicity pertaining to distribution of the 105 | software without specific, written prior permission. 106 | 107 | The author disclaims all warranties with regard to this 108 | software, including all implied warranties of merchantability 109 | and fitness. In no event shall the author be liable for any 110 | special, indirect or consequential damages or any damages 111 | whatsoever resulting from loss of use, data or profits, whether 112 | in an action of contract, negligence or other tortious action, 113 | arising out of or in connection with the use or performance of 114 | this software. 115 | ``` 116 | -------------------------------------------------------------------------------- /SampleI3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yvesh/python-elgato-streamdeck/1339c5fa6907294b033c2219a0da35de4b60feb3/SampleI3.jpg -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | SPHINXPROJ = python-elgato-streamdeck 8 | SOURCEDIR = source 9 | BUILDDIR = build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=source 11 | set BUILDDIR=build 12 | set SPHINXPROJ=python-elgato-streamdeck 13 | 14 | if "%1" == "" goto help 15 | 16 | %SPHINXBUILD% >NUL 2>NUL 17 | if errorlevel 9009 ( 18 | echo. 19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 20 | echo.installed, then set the SPHINXBUILD environment variable to point 21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 22 | echo.may add the Sphinx directory to PATH. 23 | echo. 24 | echo.If you don't have Sphinx installed, grab it from 25 | echo.http://sphinx-doc.org/ 26 | exit /b 1 27 | ) 28 | 29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 30 | goto end 31 | 32 | :help 33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% 34 | 35 | :end 36 | popd 37 | -------------------------------------------------------------------------------- /doc/source/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # 4 | # python-elgato-streamdeck documentation build configuration file, created by 5 | # sphinx-quickstart on Sun Jan 14 18:41:12 2018. 6 | # 7 | # This file is execfile()d with the current directory set to its 8 | # containing dir. 9 | # 10 | # Note that not all possible configuration values are present in this 11 | # autogenerated file. 12 | # 13 | # All configuration values have a default; values that are commented out 14 | # serve to show the default. 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | # 20 | import os 21 | import sys 22 | sys.path.insert(0, os.path.abspath('../../src/StreamDeck')) 23 | 24 | 25 | # -- General configuration ------------------------------------------------ 26 | 27 | # If your documentation needs a minimal Sphinx version, state it here. 28 | # 29 | # needs_sphinx = '1.0' 30 | 31 | # Add any Sphinx extension module names here, as strings. They can be 32 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 33 | # ones. 34 | extensions = ['sphinx.ext.autodoc'] 35 | 36 | # Add any paths that contain templates here, relative to this directory. 37 | templates_path = ['_templates'] 38 | 39 | # The suffix(es) of source filenames. 40 | # You can specify multiple suffix as a list of string: 41 | # 42 | # source_suffix = ['.rst', '.md'] 43 | source_suffix = '.rst' 44 | 45 | # The master toctree document. 46 | master_doc = 'index' 47 | 48 | # General information about the project. 49 | project = 'python-elgato-streamdeck' 50 | copyright = '2018, Dean Camera' 51 | author = 'Dean Camera' 52 | 53 | # The version info for the project you're documenting, acts as replacement for 54 | # |version| and |release|, also used in various other places throughout the 55 | # built documents. 56 | # 57 | # The short X.Y version. 58 | version = '' 59 | # The full version, including alpha/beta/rc tags. 60 | release = '' 61 | 62 | # The language for content autogenerated by Sphinx. Refer to documentation 63 | # for a list of supported languages. 64 | # 65 | # This is also used if you do content translation via gettext catalogs. 66 | # Usually you set "language" from the command line for these cases. 67 | language = None 68 | 69 | # List of patterns, relative to source directory, that match files and 70 | # directories to ignore when looking for source files. 71 | # This patterns also effect to html_static_path and html_extra_path 72 | exclude_patterns = [] 73 | 74 | # The name of the Pygments (syntax highlighting) style to use. 75 | pygments_style = 'sphinx' 76 | 77 | # If true, `todo` and `todoList` produce output, else they produce nothing. 78 | todo_include_todos = False 79 | 80 | autoclass_content = 'both' 81 | 82 | # -- Options for HTML output ---------------------------------------------- 83 | 84 | # The theme to use for HTML and HTML Help pages. See the documentation for 85 | # a list of builtin themes. 86 | # 87 | import sphinx_rtd_theme 88 | html_theme = "sphinx_rtd_theme" 89 | html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] 90 | 91 | # Theme options are theme-specific and customize the look and feel of a theme 92 | # further. For a list of options available for each theme, see the 93 | # documentation. 94 | # 95 | # html_theme_options = {} 96 | 97 | # Add any paths that contain custom static files (such as style sheets) here, 98 | # relative to this directory. They are copied after the builtin static files, 99 | # so a file named "default.css" will overwrite the builtin "default.css". 100 | html_static_path = ['_static'] 101 | 102 | # Custom sidebar templates, must be a dictionary that maps document names 103 | # to template names. 104 | # 105 | # This is required for the alabaster theme 106 | # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars 107 | html_sidebars = { 108 | '**': [ 109 | 'relations.html', # needs 'show_related': True theme option to display 110 | 'searchbox.html', 111 | ] 112 | } 113 | 114 | 115 | # -- Options for HTMLHelp output ------------------------------------------ 116 | 117 | # Output file base name for HTML help builder. 118 | htmlhelp_basename = 'python-elgato-streamdeckdoc' 119 | 120 | 121 | # -- Options for LaTeX output --------------------------------------------- 122 | 123 | latex_elements = { 124 | # The paper size ('letterpaper' or 'a4paper'). 125 | # 126 | # 'papersize': 'letterpaper', 127 | 128 | # The font size ('10pt', '11pt' or '12pt'). 129 | # 130 | # 'pointsize': '10pt', 131 | 132 | # Additional stuff for the LaTeX preamble. 133 | # 134 | # 'preamble': '', 135 | 136 | # Latex figure (float) alignment 137 | # 138 | # 'figure_align': 'htbp', 139 | } 140 | 141 | # Grouping the document tree into LaTeX files. List of tuples 142 | # (source start file, target name, title, 143 | # author, documentclass [howto, manual, or own class]). 144 | latex_documents = [ 145 | (master_doc, 'python-elgato-streamdeck.tex', 'python-elgato-streamdeck Documentation', 146 | 'Dean Camera', 'manual'), 147 | ] 148 | 149 | 150 | # -- Options for manual page output --------------------------------------- 151 | 152 | # One entry per manual page. List of tuples 153 | # (source start file, name, description, authors, manual section). 154 | man_pages = [ 155 | (master_doc, 'python-elgato-streamdeck', 'python-elgato-streamdeck Documentation', 156 | [author], 1) 157 | ] 158 | 159 | 160 | # -- Options for Texinfo output ------------------------------------------- 161 | 162 | # Grouping the document tree into Texinfo files. List of tuples 163 | # (source start file, target name, title, author, 164 | # dir menu entry, description, category) 165 | texinfo_documents = [ 166 | (master_doc, 'python-elgato-streamdeck', 'python-elgato-streamdeck Documentation', 167 | author, 'python-elgato-streamdeck', 'One line description of project.', 168 | 'Miscellaneous'), 169 | ] 170 | 171 | 172 | 173 | -------------------------------------------------------------------------------- /doc/source/index.rst: -------------------------------------------------------------------------------- 1 | python-elgato-streamdeck 2 | ==================================================== 3 | 4 | This is an open source Python 3 library to control an 5 | `Elgato Stream Deck `_ directly, 6 | without the official software. This can allow you to create your own custom 7 | front-ends, such as a custom control front-end for home automation software. 8 | 9 | Credits 10 | ==================== 11 | 12 | I've used the reverse engineering notes from 13 | `this GitHub `_ 14 | repository to implement this library. Thanks Alex Van Camp! 15 | 16 | Status 17 | ==================== 18 | 19 | Working - you can enumerate devices, set the brightness of the panel(s), set 20 | the images shown on each button, and read the current button states. 21 | 22 | Dependencies 23 | ==================== 24 | 25 | The library core has no special dependencies, but does use one of (potentially) 26 | several HID backend libraries. You will need to install the dependencies 27 | appropriate to your chosen backend. 28 | 29 | HIDAPI Backend 30 | ******************** 31 | 32 | The default backend is the HIDAPI Python library, which should work across 33 | the three major (Windows, Mac, Linux) OSes. 34 | 35 | Installation: 36 | ``` 37 | pip3 install hidapi 38 | ``` 39 | 40 | License 41 | ==================== 42 | 43 | Released under the MIT license: 44 | 45 | ``` 46 | Permission to use, copy, modify, and distribute this software 47 | and its documentation for any purpose is hereby granted without 48 | fee, provided that the above copyright notice appear in all 49 | copies and that both that the copyright notice and this 50 | permission notice and warranty disclaimer appear in supporting 51 | documentation, and that the name of the author not be used in 52 | advertising or publicity pertaining to distribution of the 53 | software without specific, written prior permission. 54 | 55 | The author disclaims all warranties with regard to this 56 | software, including all implied warranties of merchantability 57 | and fitness. In no event shall the author be liable for any 58 | special, indirect or consequential damages or any damages 59 | whatsoever resulting from loss of use, data or profits, whether 60 | in an action of contract, negligence or other tortious action, 61 | arising out of or in connection with the use or performance of 62 | this software. 63 | ``` 64 | 65 | * :ref:`genindex` 66 | * :ref:`modindex` 67 | * :ref:`search` 68 | 69 | .. toctree:: 70 | :maxdepth: 2 71 | :caption: Contents: 72 | 73 | .. automodule:: StreamDeck 74 | :members: 75 | 76 | .. automodule:: Transport.HIDAPI 77 | :members: 78 | 79 | -------------------------------------------------------------------------------- /src/Assets/Emoji Icon License.txt: -------------------------------------------------------------------------------- 1 | Emoji Icons by bukeicon: 2 | 3 | https://www.iconfinder.com/bukeicon 4 | https://www.iconfinder.com/iconsets/emoji-18 5 | 6 | 7 | ============================================= 8 | 9 | License 10 | 11 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 12 | 13 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 14 | 15 | 1. Definitions 16 | 17 | "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. 18 | "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License. 19 | "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. 20 | "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. 21 | "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. 22 | "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. 23 | "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 24 | "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. 25 | "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 26 | 27 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 28 | 29 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 30 | 31 | to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; 32 | to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; 33 | to Distribute and Publicly Perform the Work including as incorporated in Collections; and, 34 | to Distribute and Publicly Perform Adaptations. 35 | 36 | For the avoidance of doubt: 37 | Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; 38 | Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and, 39 | Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License. 40 | 41 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved. 42 | 43 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 44 | 45 | You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(b), as requested. 46 | If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4 (b) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. 47 | Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. 48 | 49 | 5. Representations, Warranties and Disclaimer 50 | 51 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 52 | 53 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 54 | 55 | 7. Termination 56 | 57 | This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 58 | Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 59 | 60 | 8. Miscellaneous 61 | 62 | Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 63 | Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. 64 | If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 65 | No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. 66 | This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. 67 | The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. 68 | -------------------------------------------------------------------------------- /src/Assets/Exit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yvesh/python-elgato-streamdeck/1339c5fa6907294b033c2219a0da35de4b60feb3/src/Assets/Exit.png -------------------------------------------------------------------------------- /src/Assets/Font Awesome 5 Free-Solid-900.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yvesh/python-elgato-streamdeck/1339c5fa6907294b033c2219a0da35de4b60feb3/src/Assets/Font Awesome 5 Free-Solid-900.otf -------------------------------------------------------------------------------- /src/Assets/Gradient Icons License.txt: -------------------------------------------------------------------------------- 1 | Gradient Icons by Abhishek Pipalva 2 | 3 | https://www.iconfinder.com/abhishekpipalva 4 | 5 | ============================================= 6 | 7 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE LEGAL SERVICES. DISTRIBUTION OF THIS LICENSE DOES NOT CREATE AN ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES REGARDING THE INFORMATION PROVIDED, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM ITS USE. 8 | 9 | License 10 | 11 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 12 | 13 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 14 | 15 | 1. Definitions 16 | 17 | "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. 18 | "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined below) for the purposes of this License. 19 | "Creative Commons Compatible License" means a license that is listed at https://creativecommons.org/compatiblelicenses that has been approved by Creative Commons as being essentially equivalent to this License, including, at a minimum, because that license: (i) contains terms that have the same purpose, meaning and effect as the License Elements of this License; and, (ii) explicitly permits the relicensing of adaptations of works made available under that license under this License or a Creative Commons jurisdiction license with the same License Elements as this License. 20 | "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. 21 | "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike. 22 | "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. 23 | "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. 24 | "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. 25 | "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 26 | "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. 27 | "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 28 | 29 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 30 | 31 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 32 | 33 | to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; 34 | to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; 35 | to Distribute and Publicly Perform the Work including as incorporated in Collections; and, 36 | to Distribute and Publicly Perform Adaptations. 37 | 38 | For the avoidance of doubt: 39 | Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; 40 | Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and, 41 | Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License. 42 | 43 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved. 44 | 45 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 46 | 47 | You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(c), as requested. 48 | You may Distribute or Publicly Perform an Adaptation only under the terms of: (i) this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible License. If you license the Adaptation under one of the licenses mentioned in (iv), you must comply with the terms of that license. If you license the Adaptation under the terms of any of the licenses mentioned in (i), (ii) or (iii) (the "Applicable License"), you must comply with the terms of the Applicable License generally and the following provisions: (I) You must include a copy of, or the URI for, the Applicable License with every copy of each Adaptation You Distribute or Publicly Perform; (II) You may not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License; (III) You must keep intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform; (IV) when You Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License. 49 | If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Ssection 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. 50 | Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. 51 | 52 | 5. Representations, Warranties and Disclaimer 53 | 54 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 55 | 56 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 57 | 58 | 7. Termination 59 | 60 | This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 61 | Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 62 | 63 | 8. Miscellaneous 64 | 65 | Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 66 | Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. 67 | If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 68 | No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. 69 | This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. 70 | The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. 71 | 72 | Creative Commons Notice 73 | 74 | Creative Commons is not a party to this License, and makes no warranty whatsoever in connection with the Work. Creative Commons will not be liable to You or any party on any legal theory for any damages whatsoever, including without limitation any general, special, incidental or consequential damages arising in connection to this license. Notwithstanding the foregoing two (2) sentences, if Creative Commons has expressly identified itself as the Licensor hereunder, it shall have all rights and obligations of Licensor. 75 | 76 | Except for the limited purpose of indicating to the public that the Work is licensed under the CCPL, Creative Commons does not authorize the use by either party of the trademark "Creative Commons" or any related trademark or logo of Creative Commons without the prior written consent of Creative Commons. Any permitted use will be in compliance with Creative Commons' then-current trademark usage guidelines, as may be published on its website or otherwise made available upon request from time to time. For the avoidance of doubt, this trademark restriction does not form part of the License. 77 | 78 | Creative Commons may be contacted at https://creativecommons.org/. 79 | -------------------------------------------------------------------------------- /src/Assets/Pressed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yvesh/python-elgato-streamdeck/1339c5fa6907294b033c2219a0da35de4b60feb3/src/Assets/Pressed.png -------------------------------------------------------------------------------- /src/Assets/Released.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yvesh/python-elgato-streamdeck/1339c5fa6907294b033c2219a0da35de4b60feb3/src/Assets/Released.png -------------------------------------------------------------------------------- /src/Assets/Roboto License.txt: -------------------------------------------------------------------------------- 1 | Roboto Font by Google: 2 | 3 | https://fonts.google.com/specimen/Roboto 4 | 5 | 6 | ============================================= 7 | 8 | Full License Text 9 | 10 | Apache License, Version 2.0 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ 11 | 12 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 13 | 14 | 1. Definitions. 15 | 16 | "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. 17 | 18 | "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. 19 | 20 | "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 21 | 22 | "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. 23 | 24 | "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. 25 | 26 | "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. 27 | 28 | "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). 29 | 30 | "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. 31 | 32 | "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." 33 | 34 | "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 35 | 36 | 2. Grant of Copyright License. 37 | 38 | Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 39 | 40 | 3. Grant of Patent License. 41 | 42 | Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 43 | 44 | 4. Redistribution. 45 | 46 | You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: 47 | 48 | You must give any other recipients of the Work or Derivative Works a copy of this License; and You must cause any modified files to carry prominent notices stating that You changed the files; and You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 49 | 50 | 5. Submission of Contributions. 51 | 52 | Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 53 | 54 | 6. Trademarks. 55 | 56 | This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 57 | 58 | 7. Disclaimer of Warranty. 59 | 60 | Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 61 | 62 | 8. Limitation of Liability. 63 | 64 | In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 65 | 66 | 9. Accepting Warranty or Additional Liability. 67 | 68 | While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. 69 | 70 | END OF TERMS AND CONDITIONS 71 | 72 | APPENDIX: How to apply the Apache License to your work 73 | 74 | To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. 75 | 76 | Copyright [yyyy] [name of copyright owner] 77 | 78 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at 79 | 80 | http://www.apache.org/licenses/LICENSE-2.0 81 | 82 | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 83 | -------------------------------------------------------------------------------- /src/Assets/Roboto Mono for Powerline.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yvesh/python-elgato-streamdeck/1339c5fa6907294b033c2219a0da35de4b60feb3/src/Assets/Roboto Mono for Powerline.ttf -------------------------------------------------------------------------------- /src/Assets/Roboto-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yvesh/python-elgato-streamdeck/1339c5fa6907294b033c2219a0da35de4b60feb3/src/Assets/Roboto-Regular.ttf -------------------------------------------------------------------------------- /src/Assets/i3_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yvesh/python-elgato-streamdeck/1339c5fa6907294b033c2219a0da35de4b60feb3/src/Assets/i3_logo.png -------------------------------------------------------------------------------- /src/I3/I3Helper.py: -------------------------------------------------------------------------------- 1 | import i3ipc 2 | import mss 3 | import mss.tools 4 | from PIL import Image, ImageDraw, ImageFont 5 | from Icon.IconHelper import IconHelper 6 | 7 | 8 | # Wrapper around i3 9 | class I3Helper(object): 10 | def __init__(self, deck, config): 11 | self.deck = deck 12 | self.config = config 13 | self.i3 = i3ipc.Connection() 14 | self.workspaces = self.i3.get_workspaces() 15 | self.image_format = deck.key_image_format() 16 | self.default_icon = Image.open('Assets/i3_logo.png').convert("RGBA") 17 | 18 | def get_key_config(self, key): 19 | # Make sure we have a Key config 20 | for k in self.config: 21 | if k['key'] == key: 22 | return k 23 | 24 | return None 25 | 26 | def get_key_image(self, key, state): 27 | key_config = self.get_key_config(key) 28 | 29 | if key_config["type"] == "workspace": 30 | return self.get_key_workspace_image(key_config) 31 | elif key_config["type"] in ["exit", "reload", "layout", "dummy"]: 32 | return IconHelper.prepare_fontawesome_image(self.image_format, key_config['icon'], key_config['text']) 33 | 34 | def get_workspace(self, key): 35 | for w in self.workspaces: 36 | if w.num == key: 37 | return w 38 | 39 | return None 40 | 41 | def get_key_workspace_image(self, key_config): 42 | # Check if workspace is visible 43 | workspace = None 44 | 45 | for ws in self.workspaces: 46 | if ws.num == key_config['workspace'] and ws.visible: 47 | workspace = ws 48 | 49 | if workspace: 50 | rect = workspace.rect 51 | 52 | with mss.mss() as sct: 53 | monitor = {"top": rect.y, "left": rect.x, "width": rect.width, "height": rect.height} 54 | raw_img = sct.grab(monitor) 55 | img = Image.frombytes("RGB", raw_img.size, raw_img.rgb).convert('RGBA') 56 | else: 57 | # Default i3 Icon 58 | img = self.default_icon 59 | 60 | return IconHelper.prepare_image(self.image_format, img, key_config['text']) 61 | 62 | def go_to_workspace(self, workspace): 63 | self.i3.command("workspace number " + str(workspace)) 64 | 65 | # Update workspaces (could be changed) 66 | self.workspaces = self.i3.get_workspaces() 67 | 68 | def switch_layout(self, key_config): 69 | self.i3.command("layout " + key_config["layout"]) 70 | 71 | # Update workspaces (could be changed) 72 | self.workspaces = self.i3.get_workspaces() 73 | 74 | def reload(self): 75 | self.i3.command("reload") 76 | 77 | def exit(self): 78 | self.i3.command("exit") 79 | -------------------------------------------------------------------------------- /src/Icon/IconHelper.py: -------------------------------------------------------------------------------- 1 | from PIL import Image, ImageDraw, ImageFont 2 | import fontawesome as fa 3 | 4 | 5 | class IconHelper: 6 | @staticmethod 7 | def prepare_fontawesome_image(image_format, icon, text): 8 | rgb_order = image_format['order'] 9 | width = image_format['width'] 10 | height = image_format['height'] 11 | 12 | img = Image.new("RGB", (width, height), "black") 13 | 14 | # Draw icon 15 | if icon: 16 | font = ImageFont.truetype("Assets/Font Awesome 5 Free-Solid-900.otf", 40) 17 | draw = ImageDraw.Draw(img) 18 | draw.text((15, 5), text=fa.icons[icon], font=font, fill=(255, 255, 255, 255)) 19 | 20 | # Load a custom TrueType font and use it to overlay the key index, draw key 21 | # number onto the image 22 | font = ImageFont.truetype("Assets/Roboto Mono for Powerline.ttf", 16) 23 | draw = ImageDraw.Draw(img) 24 | draw.text((2, height - 20), text=text, font=font, fill=(255, 255, 255, 255)) 25 | 26 | r, g, b = img.transpose(Image.FLIP_LEFT_RIGHT).split() 27 | 28 | # Recombine the B, G and R elements in the order the display expects them, 29 | # and convert the resulting image to a sequence of bytes 30 | rgb = {"R": r, "G": g, "B": b} 31 | return Image.merge("RGB", (rgb[rgb_order[0]], rgb[rgb_order[1]], rgb[rgb_order[2]])).tobytes() 32 | 33 | @staticmethod 34 | def prepare_image(image_format, icon, text): 35 | rgb_order = image_format['order'] 36 | width = image_format['width'] 37 | height = image_format['height'] 38 | 39 | img = Image.new("RGB", (width, height), "black") 40 | 41 | # RGB Icon 42 | icon.thumbnail((width, height), Image.LANCZOS) 43 | 44 | img.paste(icon, (0, 0), icon) 45 | 46 | # Load a custom TrueType font and use it to overlay the key index, draw key 47 | # number onto the image 48 | font = ImageFont.truetype("Assets/Roboto Mono for Powerline.ttf", 16) 49 | draw = ImageDraw.Draw(img) 50 | draw.text((30, height - 20), text=text, font=font, fill=(255, 0, 128, 255)) 51 | 52 | # Get the raw r, g and b components of the generated image (note we need to 53 | # flip it horizontally to match the format the StreamDeck expects) 54 | r, g, b = img.transpose(Image.FLIP_LEFT_RIGHT).split() 55 | 56 | # Recombine the B, G and R elements in the order the display expects them, 57 | # and convert the resulting image to a sequence of bytes 58 | rgb = {"R": r, "G": g, "B": b} 59 | return Image.merge("RGB", (rgb[rgb_order[0]], rgb[rgb_order[1]], rgb[rgb_order[2]])).tobytes() -------------------------------------------------------------------------------- /src/StreamDeck/StreamDeck.py: -------------------------------------------------------------------------------- 1 | # Python Stream Deck Library 2 | # Released under the MIT license 3 | # 4 | # dean [at] fourwalledcubicle [dot] com 5 | # www.fourwalledcubicle.com 6 | # 7 | 8 | import threading 9 | 10 | 11 | class DeviceManager(object): 12 | """ 13 | Central device manager, to enumerate any attached StreamDeck devices. An 14 | instance of this class must be created in order to detect and use any 15 | StreamDeck devices. 16 | """ 17 | 18 | USB_VID_ELGATO = 0x0fd9 19 | USB_PID_STREAMDECK = 0x0060 20 | 21 | @staticmethod 22 | def _get_transport(transport): 23 | """ 24 | Creates a new HID transport instance from the given transport back-end 25 | name. 26 | 27 | :param str transport: Name of a supported HID transport back-end to use. 28 | 29 | :rtype: Transport.* instance 30 | :return: Instance of a HID Transport class 31 | """ 32 | if transport == "hidapi": 33 | from .Transport.HIDAPI import HIDAPI 34 | return HIDAPI() 35 | else: 36 | raise IOError("Invalid HID transport backend \"{}\".".format(transport)) 37 | 38 | def __init__(self, transport="hidapi"): 39 | """ 40 | Creates a new StreamDeck DeviceManager, used to detect attached StreamDeck devices. 41 | 42 | :param str transport: name of the the HID transport backend to use 43 | """ 44 | self.transport = self._get_transport(transport) 45 | 46 | def enumerate(self): 47 | """ 48 | Detect attached StreamDeck devices. 49 | 50 | :rtype: list(StreamDeck) 51 | :return: list of :class:`StreamDeck` instances, one for each detected device. 52 | """ 53 | 54 | deck_devices = self.transport.enumerate( 55 | vid=self.USB_VID_ELGATO, pid=self.USB_PID_STREAMDECK) 56 | return [StreamDeck(d) for d in deck_devices] 57 | 58 | 59 | class StreamDeck(object): 60 | """ 61 | Represents a physically attached StreamDeck device. 62 | """ 63 | 64 | KEY_COUNT = 15 65 | KEY_COLS = 5 66 | KEY_ROWS = 3 67 | 68 | KEY_PIXEL_WIDTH = 72 69 | KEY_PIXEL_HEIGHT = 72 70 | KEY_PIXEL_DEPTH = 3 71 | KEY_PIXEL_ORDER = "BGR" 72 | 73 | KEY_IMAGE_SIZE = KEY_PIXEL_WIDTH * KEY_PIXEL_HEIGHT * KEY_PIXEL_DEPTH 74 | 75 | def __init__(self, device): 76 | self.device = device 77 | self.last_key_states = [False] * self.KEY_COUNT 78 | self.read_thread = None 79 | self.key_callback = None 80 | 81 | def __del__(self): 82 | """ 83 | Deletion handler for the StreamDeck, automatically closing the transport 84 | if it is currently open and terminating the transport reader thread. 85 | """ 86 | try: 87 | self._setup_reader(None) 88 | 89 | self.device.close() 90 | except Exception: 91 | pass 92 | 93 | def _read(self): 94 | """ 95 | Read handler for the underlying transport, listening for button state 96 | changes on the underlying device, caching the new states and firing off 97 | any registered callbacks. 98 | """ 99 | while self.read_thread_run: 100 | payload = [] 101 | 102 | try: 103 | payload = self.device.read(17) 104 | except ValueError: 105 | self.read_thread_run = False 106 | 107 | if len(payload): 108 | new_key_states = [bool(s) for s in payload[1:]] 109 | 110 | if self.key_callback is not None: 111 | for k, (old, new) in enumerate(zip(self.last_key_states, new_key_states)): 112 | if old != new: 113 | self.key_callback(self, k, new) 114 | 115 | self.last_key_states = new_key_states 116 | 117 | def _setup_reader(self, callback): 118 | """ 119 | Sets up the internal transport reader thread with the given callback, 120 | for asynchronous processing of HID events from the device. IF the thread 121 | already exists, it is terminated and restarted with the new callback 122 | function. 123 | 124 | :param function callback: Callback to run on the reader thread. 125 | """ 126 | if self.read_thread is not None: 127 | self.read_thread_run = False 128 | self.read_thread.join() 129 | 130 | if callback is not None: 131 | self.read_thread_run = True 132 | self.read_thread = threading.Thread(target=callback) 133 | self.read_thread.daemon = True 134 | self.read_thread.start() 135 | 136 | def open(self): 137 | """ 138 | Opens the device for input/output. This must be called prior to setting 139 | or retrieving any device state. 140 | 141 | .. seealso:: See :func:`~StreamDeck.close` for the corresponding close method. 142 | """ 143 | self.device.open() 144 | self._setup_reader(self._read) 145 | 146 | def close(self): 147 | """ 148 | Closes the device for input/output. 149 | 150 | .. seealso:: See :func:`~StreamDeck.open` for the corresponding open method. 151 | """ 152 | self.device.close() 153 | 154 | def connected(self): 155 | """ 156 | Indicates if the physical StreamDeck device this instance is attached to 157 | is still connected to the host. 158 | 159 | :rtype: bool 160 | :return: `True` if the deck is still connected, `False` otherwise. 161 | """ 162 | return self.device.connected() 163 | 164 | def id(self): 165 | """ 166 | Retrieves the physical ID of the attached StreamDeck. This can be used 167 | to differentiate one StreamDeck from another. 168 | 169 | :rtype: str 170 | :return: Identifier for the attached device. 171 | """ 172 | return self.device.path() 173 | 174 | def key_count(self): 175 | """ 176 | Retrieves number of physical buttons on the attached StreamDeck device. 177 | 178 | :rtype: int 179 | :return: Number of physical buttons. 180 | """ 181 | return self.KEY_COUNT 182 | 183 | def key_layout(self): 184 | """ 185 | Retrieves the physical button layout on the attached StreamDeck device. 186 | 187 | :rtype: (int, int) 188 | :return (rows, columns): Number of button rows and columns. 189 | """ 190 | return self.KEY_ROWS, self.KEY_COLS 191 | 192 | def key_image_format(self): 193 | """ 194 | Retrieves the image format accepted by the attached StreamDeck device. 195 | Images should be given in this format when setting an image on a button. 196 | 197 | .. seealso:: See :func:`~StreamDeck.set_key_image` method to update the 198 | image displayed on a StreamDeck button. 199 | 200 | :rtype: dict() 201 | :return: Dictionary describing the various image parameters 202 | (width, height, pixel depth and RGB order). 203 | """ 204 | return { 205 | "width": self.KEY_PIXEL_WIDTH, 206 | "height": self.KEY_PIXEL_HEIGHT, 207 | "depth": self.KEY_PIXEL_DEPTH, 208 | "order": self.KEY_PIXEL_ORDER, 209 | } 210 | 211 | def reset(self): 212 | """ 213 | Resets the StreamDeck, clearing all button images and showing the 214 | standby image. 215 | """ 216 | 217 | payload = bytearray(17) 218 | payload[0:2] = [0x0B, 0x63] 219 | self.device.write_feature(payload) 220 | 221 | def set_brightness(self, percent): 222 | """ 223 | Sets the global screen brightness of the ScreenDeck, across all the 224 | physical buttons. 225 | 226 | :param int/float percent: brightness percent, from [0-100] as an `int`, 227 | or normalized to [0.0-1.0] as a `float`. 228 | """ 229 | 230 | if type(percent) is float: 231 | percent = int(100.0 * percent) 232 | 233 | percent = min(max(percent, 0), 100) 234 | 235 | payload = bytearray(17) 236 | payload[0:6] = [0x05, 0x55, 0xaa, 0xd1, 0x01, percent] 237 | self.device.write_feature(payload) 238 | 239 | def set_key_image(self, key, image): 240 | """ 241 | Sets the image of a button on the StremDeck to the given image. The 242 | image being set should be in the correct format for the device, as an 243 | enumerable collection of pixels. 244 | 245 | .. seealso:: See :func:`~StreamDeck.get_key_image_format` method for 246 | information on the image format accepted by the device. 247 | 248 | :param int key: Index of the button whose image is to be updated. 249 | :param enumerable image: Pixel data of the image to set on the button. 250 | If `None`, the key will be cleared to a black 251 | color. 252 | """ 253 | 254 | image = bytes(image or self.KEY_IMAGE_SIZE) 255 | 256 | if min(max(key, 0), self.KEY_COUNT) != key: 257 | raise IndexError("Invalid key index {}.".format(key)) 258 | 259 | if len(image) != self.KEY_IMAGE_SIZE: 260 | raise ValueError("Invalid image size {}.".format(len(image))) 261 | 262 | header_1 = [ 263 | 0x02, 0x01, 0x01, 0x00, 0x00, key + 1, 0x00, 0x00, 264 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 265 | 0x42, 0x4d, 0xf6, 0x3c, 0x00, 0x00, 0x00, 0x00, 266 | 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00, 267 | 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x48, 0x00, 268 | 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x00, 0x00, 269 | 0x00, 0x00, 0xc0, 0x3c, 0x00, 0x00, 0xc4, 0x0e, 270 | 0x00, 0x00, 0xc4, 0x0e, 0x00, 0x00, 0x00, 0x00, 271 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 272 | ] 273 | header_2 = [ 274 | 0x02, 0x01, 0x02, 0x00, 0x01, key + 1, 0x00, 0x00, 275 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 276 | ] 277 | 278 | IMAGE_BYTES_PAGE_1 = 2583 * 3 279 | 280 | payload_1 = bytes(header_1) + image[: IMAGE_BYTES_PAGE_1] 281 | payload_2 = bytes(header_2) + image[IMAGE_BYTES_PAGE_1:] 282 | 283 | self.device.write(payload_1) 284 | self.device.write(payload_2) 285 | 286 | def set_key_callback(self, callback): 287 | """ 288 | Sets the callback function called each time a button on the StreamDeck 289 | changes state (either pressed, or released). 290 | 291 | .. note:: This callback will be fired from an internal reader thread. 292 | Ensure that the given callback function is thread-safe. 293 | 294 | .. note:: Only one callback can be registered at one time. 295 | 296 | .. seealso:: See :func:`~StreamDeck.set_key_callback_async` method for 297 | a version compatible with Python 3 `asyncio` asynchronous 298 | functions. 299 | 300 | :param function callback: Callback function to fire each time a button 301 | state changes. 302 | """ 303 | self.key_callback = callback 304 | 305 | def set_key_callback_async(self, async_callback, loop=None): 306 | """ 307 | Sets the asynchronous callback function called each time a button on the 308 | StreamDeck changes state (either pressed, or released). The given 309 | callback should be compatible with Python 3's `asyncio` routines. 310 | 311 | .. note:: The asynchronous callback will be fired in a thread-safe 312 | manner. 313 | 314 | .. note:: This will override the callback (if any) set by 315 | :func:`~StreamDeck.set_key_callback`. 316 | 317 | :param function async_callback: Asynchronous callback function to fire 318 | each time a button state changes. 319 | :param function loop: Asyncio loop to dispatch the callback into 320 | """ 321 | import asyncio 322 | 323 | loop = loop or asyncio.get_event_loop() 324 | 325 | def callback(*args): 326 | asyncio.run_coroutine_threadsafe(async_callback(*args), loop) 327 | 328 | self.set_key_callback(callback) 329 | 330 | def key_states(self): 331 | """ 332 | Retrieves the current states of the buttons on the StreamDeck. 333 | 334 | :rtype: list(bool) 335 | :return: List describing the current states of each of the buttons on 336 | the device (`True` if the button is being pressed, 337 | `False` otherwise). 338 | """ 339 | return self.last_key_states 340 | -------------------------------------------------------------------------------- /src/StreamDeck/Transport/HIDAPI.py: -------------------------------------------------------------------------------- 1 | # Python Stream Deck Library 2 | # Released under the MIT license 3 | # 4 | # dean [at] fourwalledcubicle [dot] com 5 | # www.fourwalledcubicle.com 6 | # 7 | 8 | # pip3 install hidapi (https://pypi.python.org/pypi/hidapi/0.7.99.post8) 9 | 10 | import hid 11 | 12 | 13 | class HIDAPI(object): 14 | """ 15 | USB HID transport layer, using the `hidapi` Python wrapper. This transport 16 | can be used to enumerate and communicate with HID devices. 17 | """ 18 | 19 | class Device(object): 20 | def __init__(self, device_info): 21 | """ 22 | Creates a new HIDAPI device instance, used to send and receive HID 23 | reports from/to an attached USB HID device. 24 | 25 | :param dict() device_info: Device information dictionary describing 26 | a single unique attached USB HID device. 27 | """ 28 | self.hid_info = device_info 29 | self.hid = hid.device() 30 | 31 | def __del__(self): 32 | """ 33 | Deletion handler for the HIDAPI transport, automatically closing the 34 | device if it is currently open. 35 | """ 36 | try: 37 | self.hid.close() 38 | except Exception: 39 | pass 40 | 41 | def open(self): 42 | """ 43 | Opens the HID device for input/output. This must be called prior to 44 | sending or receiving any HID reports. 45 | 46 | .. seealso:: See :func:`~HIDAPI.Device.close` for the corresponding 47 | close method. 48 | """ 49 | self.hid.open_path(self.hid_info['path']) 50 | 51 | def close(self): 52 | """ 53 | Closes theHID device for input/output. 54 | 55 | .. seealso:: See :func:`~~HIDAPI.Device.open` for the corresponding 56 | open method. 57 | """ 58 | self.hid.close() 59 | 60 | def connected(self): 61 | """ 62 | Indicates if the physical HID device this instance is attached to 63 | is still connected to the host. 64 | 65 | :rtype: bool 66 | :return: `True` if the device is still connected, `False` otherwise. 67 | """ 68 | devices = hid.enumerate() 69 | return any([d['path'] == self.hid_info['path'] for d in devices]) 70 | 71 | def path(self): 72 | """ 73 | Retrieves the logical path of the attached HID device within the 74 | current system. This can be used to differentiate one HID device 75 | from another. 76 | 77 | :rtype: str 78 | :return: Logical device path for the attached device. 79 | """ 80 | return self.hid_info['path'] 81 | 82 | def write_feature(self, payload): 83 | """ 84 | Sends a HID Feature report to the open HID device. 85 | 86 | :param enumerable() payload: Enumerate list of bytes to send to the 87 | device, as a feature report. The first 88 | byte of the report should be the Report 89 | ID of the report being sent. 90 | 91 | :rtype: int 92 | :return: Number of bytes successfully sent to the device. 93 | """ 94 | return self.hid.send_feature_report(payload) 95 | 96 | def write(self, payload): 97 | """ 98 | Sends a HID Out report to the open HID device. 99 | 100 | :param enumerable() payload: Enumerate list of bytes to send to the 101 | device, as an Out report. The first 102 | byte of the report should be the Report 103 | ID of the report being sent. 104 | 105 | :rtype: int 106 | :return: Number of bytes successfully sent to the device. 107 | """ 108 | return self.hid.write(payload) 109 | 110 | def read(self, length): 111 | """ 112 | Performs a blocking read of a HID In report from the open HID device. 113 | 114 | :param int length: Maximum length of the In report to read. 115 | 116 | :rtype: list() 117 | :return: List of bytes containing the read In report. The first byte 118 | of the report will be the Report ID of the report that was 119 | read. 120 | """ 121 | return self.hid.read(length) 122 | 123 | def enumerate(self, vid, pid): 124 | """ 125 | Enumerates all available USB HID devices on the system. 126 | 127 | :param int vid: USB Vendor ID to filter all devices by, `None` if the 128 | device list should not be filtered by vendor. 129 | :param int pid: USB Product ID to filter all devices by, `None` if the 130 | device list should not be filtered by product. 131 | 132 | :rtype: list(HIDAPI.Device) 133 | :return: List of discovered USB HID devices. 134 | """ 135 | 136 | if vid is None: 137 | vid = 0 138 | 139 | if pid is None: 140 | pid = 0 141 | 142 | devices = hid.enumerate(vendor_id=vid, product_id=pid) 143 | 144 | return [HIDAPI.Device(d) for d in devices] 145 | -------------------------------------------------------------------------------- /src/config.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"key": 0, "type": "workspace", "workspace": 5, "text": "5"}, 3 | {"key": 1, "type": "workspace", "workspace": 4, "text": "4"}, 4 | {"key": 2, "type": "workspace", "workspace": 3, "text": "3"}, 5 | {"key": 3, "type": "workspace", "workspace": 2, "text": "2"}, 6 | {"key": 4, "type": "workspace", "workspace": 1, "text": "1"}, 7 | {"key": 5, "type": "workspace", "workspace": 0, "text": "0"}, 8 | {"key": 6, "type": "workspace", "workspace": 9, "text": "9"}, 9 | {"key": 7, "type": "workspace", "workspace": 8, "text": "8"}, 10 | {"key": 8, "type": "workspace", "workspace": 7, "text": "7"}, 11 | {"key": 9, "type": "workspace", "workspace": 6, "text": "6"}, 12 | {"key": 10, "type": "exit", "icon": "times-circle", "text": "Exit i3"}, 13 | {"key": 11, "type": "reload", "icon": "redo-alt", "text": "Reload"}, 14 | {"key": 12, "type": "layout", "layout": "tabbed", "icon": "random", "text": "Tabbed"}, 15 | {"key": 13, "type": "layout", "layout": "stacking", "icon": "sticky-note", "text": "Stacking"}, 16 | {"key": 14, "type": "layout", "layout": "toggle split", "icon": "columns", "text": "Split"} 17 | ] 18 | -------------------------------------------------------------------------------- /src/start.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # Python Stream Deck Library 4 | # Released under the MIT license 5 | # 6 | # dean [at] fourwalledcubicle [dot] com 7 | # www.fourwalledcubicle.com 8 | # 9 | 10 | import StreamDeck.StreamDeck as StreamDeck 11 | import threading 12 | from I3.I3Helper import I3Helper 13 | import json 14 | 15 | 16 | # Creates a new key image based on the key index, style and current key state 17 | # and updates the image on the StreamDeck. 18 | def update_key_image(deck, key, state): 19 | im = i3_helper.get_key_image(key, state) 20 | 21 | deck.set_key_image(key, im) 22 | 23 | 24 | # Prints key state change information, updates rhe key image and performs any 25 | # associated actions when a key is pressed. 26 | def key_change_callback(deck, key, state): 27 | # Print new key state 28 | print("Deck {} Key {} = {}".format(deck.id(), key, state), flush=True) 29 | 30 | # Update the key image based on the new key state 31 | update_key_image(deck, key, state) 32 | 33 | # Check if the key is changing to the pressed state 34 | if state: 35 | key_config = i3_helper.get_key_config(key) 36 | 37 | # Hardcoded for now 38 | if key_config["type"] == "workspace": 39 | # Switch workspace 40 | i3_helper.go_to_workspace(key_config["workspace"]) 41 | elif key_config["type"] == "layout": 42 | i3_helper.switch_layout(key_config) 43 | elif key_config["type"] == "reload": 44 | i3_helper.reload() 45 | elif key_config["type"] == "exit": 46 | i3_helper.exit() 47 | else: 48 | print("Dummy task", key_config["type"]) 49 | 50 | 51 | def load_config(): 52 | with open("config.json", "r") as config_file: 53 | config = json.load(config_file) 54 | return config 55 | 56 | 57 | if __name__ == "__main__": 58 | manager = StreamDeck.DeviceManager() 59 | decks = manager.enumerate() 60 | config = load_config() 61 | 62 | print(config) 63 | 64 | # Hack, for now just working with one Deck 65 | i3_helper = I3Helper(decks[0], config) 66 | 67 | print("Found {} Stream Decks.".format(len(decks)), flush=True) 68 | 69 | for deck in decks: 70 | deck.open() 71 | deck.reset() 72 | 73 | deck.set_brightness(50) 74 | 75 | # Set initial key images 76 | for key in range(deck.key_count()): 77 | update_key_image(deck, key, False) 78 | 79 | # Register callback function for when a key state changes 80 | deck.set_key_callback(key_change_callback) 81 | 82 | # Wait until all application threads have terminated (for this example, 83 | # this is when all deck handles are closed) 84 | for t in threading.enumerate(): 85 | if t is threading.currentThread(): 86 | continue 87 | 88 | if t.is_alive(): 89 | t.join() 90 | -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Just for pwd 6 | cd src 7 | 8 | python3 start.py 9 | --------------------------------------------------------------------------------