[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Feature Request: Command Plugins



Hi,

I'm currently researching loadable dynamic libraries
(no prior experience), so hopefully someone with more
wisdom could weigh in.


Using glibs module system, it seems that plugins that
allow the user to add server-side commands could be
fairly easily implemented. This would keep the core
source slim, but allow people [like me, who write
stupid, inelegant, and mostly unneeded things] to
enable commands that just aren't possible with client-
side scripting, without having to deal with a patch
system/alternative branches if they want to share
their work.

This would also allow Thorsten to focus on the core
wm, without having to consider all my extraneous
patches :).

Precompiled code could be put into
$XDG_CONFIG_HOME/herbstluftwm/plugins, and loaded in
during runtime with a command like 'hc load_plugin'.

Using glibs dl routines would not introduce any new
dependencies, and they wouldn't break cross-platform
compatibility (except platforms where gmodules can't
be implemented, where 'hc ...plugin' commands could
just return an error thanks to g_module_supported())


The CommandBinding array could be refactored, preferably
imo, as a linked list. The current array could even be
kept, and then just iterated and linked on
initialization. This would make it easy to add new
built-in commands without having to hardcode the links.
Call_command(), I believe, would be the only thing
needing rewriting post-refactoring.

Implementing a second list, which call_command searches
first, is an alternative as well. This would make it
simpler to keep track of loaded modules, but would
make call_command() (which is called quite often) more
complex.

Plugins could have a init routine that just return a
CommandBinding struct, which is pushed onto the stack
once the library is loaded.


One thing I'm unsure about is the scope these external
libraries would have. Would they be able to access
the frame tree, for example? If not, this idea is
pretty useless.

Plugins would only need to exist for commands, imo,
since commands are the base of all configuration.


As I said, Im still reading up on the subject. So it
might not even be possible. But if it is, I personally
think it would be great.

Thoughts?
Tylo