FrancescoCeruti / linux-show-player

Linux Show Player - Cue player designed for stage productions
https://linux-show-player.org
GNU General Public License v3.0
205 stars 49 forks source link

Support loading plugins from a User's home directory #201

Closed s0600204 closed 4 years ago

s0600204 commented 4 years ago

gitter, December 2018:

s0600204:

Which begs the question - how do you envision plugin installation working in the future? [...] Hypothetically, how would these custom plugins be "packaged" so that someone else can easily "install" them?

FrancescoCeruti:

I've thought a bit about that, ideally you could simply have a directory in the user home (under .linux_show_player), where LiSP looks for user installed plugins. [...] They can be packaged as zip files or similar with a metadata file.

This set of changes is an attempt to permit the above.

With this PR, it is possible to place a plugin in the folder $XDG_DATA_HOME/LinuxShowPlayer/$LiSP_Version/plugins/ (e.g. ~/.local/share/LinuxShowPlayer/0.6/plugins/) and LiSP will load it on next program restart.

As an example, I've created a plugin over at https://github.com/s0600204/protocol_monitor. To test, you can clone the repo into ~/.local/share/LinuxShowPlayer/0.6/plugins/protocol_monitor (such that that is the root folder of the repo) and (re)start LiSP. (Or alternatively, move one of the plugins included with LiSP out.)

It is also possible with this PR to have a plugin zipped up. Unfortunately, downloading a zip-file from GitHub and using it directly is not possible (GitHub doesn't create the subfolder within the zip-file with the correct name), however creating a zip-file manually with the layout:

  example.zip
     '- example_plugin/
         |- __init__.py
         |- default.json
         '- example_plugin.py

should work.

There is a caveat with using a zip-file: whilst python code is included automatically, other files have to be extracted programmatically before being usable. The default.json file is example of this, and this pull-request includes code that creates a temporary folder and extracts it automatically on plugin load (the temporary folder is removed again when LiSP closes).

FrancescoCeruti commented 4 years ago

So, I've looked at it, the user directory part seems fine to me :+1:

I'm not sure about the zip loading, not the code itself, but as a feature and how useful it can be, considering that is also have a few limitations.

I think that my original idea was to provide the ability to install third-party plugins via zip file using some kind of functionality (with a UI) that would extract the archive and hide a few steps from the user.

This second approach would have the following advantages:

Since currently I don't think there will be many users for this feature we can simply add support for loading the plugins from the user directory, and at a later point we could provide all the functionality mentioned above.

This is my opinion obviously, maybe I'm missing something, if you have some counter arguments let me know :)

s0600204 commented 4 years ago

Fair enough. In which case, only the first commit is actually needed.

I'll rebase and push that so it's easier to review.