Development Tutorial ==================== Creating a Project ------------------ Ulauncher runs all extensions from ``~/.local/share/ulauncher/extensions/``. Create a new directory there (name it as you wish) with the following structure:: . ├── images │   └── icon.png ├── versions.json ├── manifest.json └── main.py * :file:`versions.json` contains mapping of Ulauncher Extension API to branch name of the extension * :file:`manifest.json` contains all necessary metadata * :file:`main.py` is an entry point for your extension * :file:`images/` contains at least an icon of you extension Check out :doc:`debugging` to learn how to test and debug your extension. versions.json ------------- ``versions.json`` lists the supported versions of Ulauncher API. It should be in to the **root** directory of the default branch. Note that before Ulauncher 5.15.0 the default branch had to be named **master**, so for compatibility reasons it's highly advised to use this name still. * ``commit`` should specify the commit hash, branch name, or git tag referencing the version. * ``required_api_version`` should contain a version string, ex "2". Example:: [ {"required_api_version": "2", "commit": "master"}, {"required_api_version": "3", "commit": "future_v3_api"} ] You can find the current version on the About page of Ulauncher preferences. **How does Ulauncher use this file?** | First, Ulauncher will download ``versions.json`` from the master branch of the extension repo. | Then it will find a required API version that matches current API version. | After that it will download extension code using a branch/tag/commit name. manifest.json ------------- Create :file:`manifest.json` using the following template:: { "required_api_version": "2", "name": "Demo extension", "description": "Extension Description", "developer_name": "John Doe", "icon": "images/icon.png", "options": { "query_debounce": 0.1 }, "preferences": [ { "id": "demo_kw", "type": "keyword", "name": "Demo", "description": "Demo extension", "default_value": "dm" } ] } * ``required_api_version`` - a version of Ulauncher Extension API that the extension requires, for example "2". You can find the current version number on the About page of Ulauncher preferences. * ``name``, ``description``, ``developer_name`` can be anything you like but not an empty string * ``icon`` - relative path to an extension icon * ``options`` - dictionary of optional parameters. See available options below * ``preferences`` - list of preferences available for users to override. They are rendered in Ulauncher preferences in the same order they are listed in manifest. .. NOTE:: All fields except ``options`` are required and cannot be empty. Available Options ^^^^^^^^^^^^^^^^^ ``query_debounce`` Default ``0.05``. Delay in seconds between event is created and sent to your extension. If a new event is created during that period, previous one is skipped. Debounce helps to prevent redundant events caused by user typing too fast or maybe some other reasons when you may not want to process events each time they are triggered. If your extension is super responsive (i.e, doesn't wait for I/O operations like network requests, file read/writes, and doesn't load CPU, you may want to set a lower value like ``0.05`` or ``0.1``. Otherwise it's recommended to set value to ``1`` or higher. Preference Object Fields ^^^^^^^^^^^^^^^^^^^^^^^^ The values of the preferences are forwarded to the ``on_event`` method of the ``KeywordQueryEventListener`` class as an attribute of extension. For example the value of the keyword with ``id = 'id'`` and ``value = 'val'`` is obtained with the line ``value = extension.preferences['id']`` which assigns the string ``'val'`` to value. An example of the use of preferences can be found in the `ulauncher demo extension `_ ``id`` (required) Key that is used to retrieve value for a certain preference ``type`` (required) Can be "keyword", "input", "text", or "select" * keyword - define keyword that user has to type in in order to use your extension * input - rendered as ```` * text - rendered as ``