Look for plugins to install in global location
Two options to install plugins. Mention the whole path: `/plugins install ~/src/profanity-plugins/my.py` Mention only the plugin name: `/plugins install my.py` The latter will look in `/usr/local/share/profanity/plugins/` for the file and copy it over to `~/.local/share/profanity/plugins`. At first I was thinking about loading the plugins from the global location. But users most likely don't want to have all plugins activated that an admin installs on a system. Regards https://github.com/profanity-im/profanity/issues/945
This commit is contained in:
28
configure.ac
28
configure.ac
@@ -96,6 +96,9 @@ elif test "x$enable_python_plugins" != xno; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
AS_IF([test "x$PLATFORM" = xosx], [rm -f Python.framework])
|
AS_IF([test "x$PLATFORM" = xosx], [rm -f Python.framework])
|
||||||
|
# set path to look for global python plugins
|
||||||
|
GLOBAL_PYTHON_PLUGINS_PATH='${pkgdatadir}/plugins'
|
||||||
|
AC_SUBST(GLOBAL_PYTHON_PLUGINS_PATH)
|
||||||
else
|
else
|
||||||
AM_CONDITIONAL([BUILD_PYTHON_API], [false])
|
AM_CONDITIONAL([BUILD_PYTHON_API], [false])
|
||||||
fi
|
fi
|
||||||
@@ -119,6 +122,9 @@ else
|
|||||||
[AC_MSG_ERROR([dl library needed to run C plugins])],
|
[AC_MSG_ERROR([dl library needed to run C plugins])],
|
||||||
[AM_CONDITIONAL([BUILD_C_API], [false])])
|
[AM_CONDITIONAL([BUILD_C_API], [false])])
|
||||||
])])
|
])])
|
||||||
|
# set path to look for global c plugins
|
||||||
|
GLOBAL_C_PLUGINS_PATH='${pkglibdir}/plugins'
|
||||||
|
AC_SUBST(GLOBAL_C_PLUGINS_PATH)
|
||||||
else
|
else
|
||||||
AM_CONDITIONAL([BUILD_C_API], [false])
|
AM_CONDITIONAL([BUILD_C_API], [false])
|
||||||
fi
|
fi
|
||||||
@@ -360,7 +366,7 @@ AS_IF([test "x$PLATFORM" = xosx],
|
|||||||
[AM_CFLAGS="$AM_CFLAGS -Qunused-arguments"])
|
[AM_CFLAGS="$AM_CFLAGS -Qunused-arguments"])
|
||||||
AM_LDFLAGS="$AM_LDFLAGS -export-dynamic"
|
AM_LDFLAGS="$AM_LDFLAGS -export-dynamic"
|
||||||
AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $gio_CFLAGS $curl_CFLAGS $libnotify_CFLAGS $PYTHON_CPPFLAGS ${GTK_CFLAGS} ${SQLITE_CFLAGS}"
|
AM_CPPFLAGS="$AM_CPPFLAGS $glib_CFLAGS $gio_CFLAGS $curl_CFLAGS $libnotify_CFLAGS $PYTHON_CPPFLAGS ${GTK_CFLAGS} ${SQLITE_CFLAGS}"
|
||||||
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\" -DICONS_PATH=\"\\\"$ICONS_PATH\\\"\""
|
AM_CPPFLAGS="$AM_CPPFLAGS -DTHEMES_PATH=\"\\\"$THEMES_PATH\\\"\" -DICONS_PATH=\"\\\"$ICONS_PATH\\\"\" -DGLOBAL_PYTHON_PLUGINS_PATH=\"\\\"$GLOBAL_PYTHON_PLUGINS_PATH\\\"\" -DGLOBAL_C_PLUGINS_PATH=\"\\\"$GLOBAL_C_PLUGINS_PATH\\\"\""
|
||||||
LIBS="$glib_LIBS $gio_LIBS $curl_LIBS $libnotify_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYTHON_LDFLAGS ${GTK_LIBS} ${SQLITE_LIBS} $LIBS"
|
LIBS="$glib_LIBS $gio_LIBS $curl_LIBS $libnotify_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYTHON_LDFLAGS ${GTK_LIBS} ${SQLITE_LIBS} $LIBS"
|
||||||
|
|
||||||
AC_SUBST(AM_LDFLAGS)
|
AC_SUBST(AM_LDFLAGS)
|
||||||
@@ -374,14 +380,16 @@ AC_CONFIG_FILES([Makefile])
|
|||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "PLATFORM : $host_os"
|
echo "PLATFORM : $host_os"
|
||||||
echo "PACKAGE_STATUS : $PACKAGE_STATUS"
|
echo "PACKAGE_STATUS : $PACKAGE_STATUS"
|
||||||
echo "AM_CFLAGS : $AM_CFLAGS"
|
echo "AM_CFLAGS : $AM_CFLAGS"
|
||||||
echo "AM_CPPFLAGS : $AM_CPPFLAGS"
|
echo "AM_CPPFLAGS : $AM_CPPFLAGS"
|
||||||
echo "AM_LDFLAGS : $AM_LDFLAGS"
|
echo "AM_LDFLAGS : $AM_LDFLAGS"
|
||||||
echo "LIBS : $LIBS"
|
echo "LIBS : $LIBS"
|
||||||
echo "Install themes : $THEMES_INSTALL"
|
echo "Install themes : $THEMES_INSTALL"
|
||||||
echo "Themes path : $THEMES_PATH"
|
echo "Themes path : $THEMES_PATH"
|
||||||
echo "Icons path : $ICONS_PATH"
|
echo "Icons path : $ICONS_PATH"
|
||||||
|
echo "Global Python plugins path : $GLOBAL_PYTHON_PLUGINS_PATH"
|
||||||
|
echo "Global C plugins path : $GLOBAL_C_PLUGINS_PATH"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Now you can run \`make' to build profanity"
|
echo "Now you can run \`make' to build profanity"
|
||||||
|
|||||||
@@ -6927,13 +6927,31 @@ cmd_receipts(ProfWin* window, const char* const command, gchar** args)
|
|||||||
gboolean
|
gboolean
|
||||||
cmd_plugins_install(ProfWin* window, const char* const command, gchar** args)
|
cmd_plugins_install(ProfWin* window, const char* const command, gchar** args)
|
||||||
{
|
{
|
||||||
char* path;
|
char* path = NULL;
|
||||||
|
|
||||||
if (args[1] == NULL) {
|
if (args[1] == NULL) {
|
||||||
cons_show("Please provide a path to the plugin file or directory, see /help plugins");
|
cons_show("Please provide a path to the plugin file or directory, see /help plugins");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
// take whole path or build it in case it's just the plugin name
|
||||||
|
if (strchr(args[1], '/')) {
|
||||||
path = get_expanded_path(args[1]);
|
path = get_expanded_path(args[1]);
|
||||||
|
} else {
|
||||||
|
if (g_str_has_suffix(args[1], ".py")) {
|
||||||
|
path = g_strdup_printf("%s/%s", GLOBAL_PYTHON_PLUGINS_PATH, args[1]);
|
||||||
|
} else if (g_str_has_suffix(args[1], ".so")) {
|
||||||
|
path = g_strdup_printf("%s/%s", GLOBAL_C_PLUGINS_PATH, args[1]);
|
||||||
|
} else {
|
||||||
|
cons_show("Plugins must have one of the following extensions: '.py' '.so'");
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (access(path, R_OK) != 0) {
|
||||||
|
cons_show("Cannot access: %s", path);
|
||||||
|
free(path);
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_regular_file(path)) {
|
if (is_regular_file(path)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user