From 04e764c8e615b03e3fe3703f79e2662539ab5349 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Fri, 21 Apr 2017 09:48:03 +0200 Subject: [PATCH] [Plugins] Add -no-plugins and -plugin-path options * -no-plugins disables the loading of plugins. * -plugin-path specifies the directory used by rofi to look for plugins. --- config/config.c | 1 + doc/rofi-manpage.markdown | 9 +++++++++ doc/rofi.1 | 12 ++++++++++++ include/settings.h | 2 ++ source/rofi.c | 9 ++++++--- source/xrmoptions.c | 2 ++ 6 files changed, 32 insertions(+), 3 deletions(-) diff --git a/config/config.c b/config/config.c index 0e2d9eba..902aee45 100644 --- a/config/config.c +++ b/config/config.c @@ -116,4 +116,5 @@ Settings config = { .color_active = NULL, .color_urgent = NULL, .color_window = NULL, + .plugin_path = PLUGIN_PATH, }; diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 0395bb19..1021b283 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -222,6 +222,15 @@ Hide the indicator that shows what part of the string is matched. Disables lazy grab, this forces the keyboard being grabbed before gui is shown. +`-no-plugins` + +Disable plugin loading. + +`-plugin-path` *directory* + +Specify the directory where *rofi* should look for plugins. + + ### Matching `-matching` *method* diff --git a/doc/rofi.1 b/doc/rofi.1 index 07751454..9519d3c2 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -312,6 +312,18 @@ Hide the indicator that shows what part of the string is matched\. .P Disables lazy grab, this forces the keyboard being grabbed before gui is shown\. . +.P +\fB\-no\-plugins\fR +. +.P +Disable plugin loading\. +. +.P +\fB\-plugin\-path\fR \fIdirectory\fR +. +.P +Specify the directory where \fIrofi\fR should look for plugins\. +. .SS "Matching" \fB\-matching\fR \fImethod\fR . diff --git a/include/settings.h b/include/settings.h index 5b82b24d..66b6101d 100644 --- a/include/settings.h +++ b/include/settings.h @@ -165,6 +165,8 @@ typedef struct gboolean show_match; char *theme; + /** Path where plugins can be found. */ + char * plugin_path; } Settings; /** Global Settings structure. */ extern Settings config; diff --git a/source/rofi.c b/source/rofi.c index a7f4a9b3..636f2787 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -305,6 +305,7 @@ static void print_main_application_options ( int is_term ) print_help_msg ( "-normal-window", "", "In dmenu mode, behave as a normal window. (experimental)", NULL, is_term ); print_help_msg ( "-show", "[mode]", "Show the mode 'mode' and exit. The mode has to be enabled.", NULL, is_term ); print_help_msg ( "-no-lazy-grab", "", "Disable lazy grab that, when fail to grab keyboard, does not block but retry later.", NULL, is_term ); + print_help_msg ( "-no-plugins", "", "Disable loading of external plugins.", NULL, is_term ); } static void help ( G_GNUC_UNUSED int argc, char **argv ) { @@ -547,7 +548,7 @@ static void rofi_collect_modi_dir ( const char *base_dir ) Mode *m = NULL; if ( g_module_symbol ( mod, "mode", (gpointer *) &m ) ) { if ( m->abi_version != ABI_VERSION ) { - g_warning ( "ABI version of plugin does not match: %08X expecting: %08X", m->abi_version, ABI_VERSION ); + g_warning ( "ABI version of plugin: '%s' does not match: %08X expecting: %08X", dn, m->abi_version, ABI_VERSION ); g_module_close ( mod ); } else { @@ -558,7 +559,7 @@ static void rofi_collect_modi_dir ( const char *base_dir ) } } else { - g_warning ( "Symbol 'mode' not found in module: %s", fn ); + g_warning ( "Symbol 'mode' not found in module: %s", dn ); g_module_close ( mod ); } } @@ -585,7 +586,9 @@ static void rofi_collect_modi ( void ) rofi_collect_modi_add ( &combi_mode ); rofi_collect_modi_add ( &help_keys_mode ); - rofi_collect_modi_dir ( PLUGIN_PATH ); + if ( find_arg ( "-no-plugins" ) < 0 ) { + rofi_collect_modi_dir ( config.plugin_path ); + } } /** diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 19b93922..b19960d4 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -180,6 +180,8 @@ static XrmOption xrmOptions[] = { "Color scheme for active row", CONFIG_DEFAULT }, { xrm_String, "color-window", { .str = &config.color_window }, NULL, "Color scheme window", CONFIG_DEFAULT }, + { xrm_String, "plugin-path", { .str = &config.plugin_path }, NULL, + "Directory containing plugins", CONFIG_DEFAULT }, }; /** Dynamic array of extra options */