Add a plugins_conf_dir option
This commit is contained in:
parent
98850ff877
commit
e861290d10
4 changed files with 26 additions and 4 deletions
|
@ -218,6 +218,10 @@ log_dir =
|
|||
# You can specify an other directory to use. It will be created if it doesn't exist
|
||||
plugins_dir =
|
||||
|
||||
# If plugins_conf_dir is not set, plugin configs will be loaded from
|
||||
# $XDG_CONFIG_HOME/poezio/plugins. You can specify another directory here.
|
||||
plugins_conf_dir =
|
||||
|
||||
# Space separated list of plugins to load on startup
|
||||
plugins_autoload =
|
||||
|
||||
|
|
|
@ -255,6 +255,13 @@ section of this documentation.
|
|||
|
||||
Space separated list of plugins to load on startup.
|
||||
|
||||
*plugins_conf_dir*:: [empty]
|
||||
|
||||
If plugins_conf_dir is not set, plugin configs will be loaded from
|
||||
$XDG_CONFIG_HOME/poezio/plugins.
|
||||
You can specify another directory to use, it will be created if it
|
||||
does not exist.
|
||||
|
||||
*plugins_dir*:: [empty]
|
||||
|
||||
If plugins_dir is not set, plugins will be loaded from
|
||||
|
|
|
@ -2032,6 +2032,9 @@ class Core(object):
|
|||
elif option == 'plugins_dir':
|
||||
path = os.path.expanduser(value)
|
||||
self.plugin_manager.on_plugins_dir_change(path)
|
||||
elif option == 'plugins_conf_dir':
|
||||
path = os.path.expanduser(value)
|
||||
self.plugin_manager.on_plugins_conf_dir_change(path)
|
||||
self.call_for_resize()
|
||||
self.information(info, "Info")
|
||||
|
||||
|
|
|
@ -25,10 +25,13 @@ plugins_dir = plugins_dir or\
|
|||
'poezio', 'plugins')
|
||||
plugins_dir = os.path.expanduser(plugins_dir)
|
||||
|
||||
config_home = os.environ.get("XDG_CONFIG_HOME")
|
||||
if not config_home:
|
||||
config_home = os.path.join(os.environ.get('HOME'), '.config')
|
||||
plugins_conf_dir = os.path.join(config_home, 'poezio', 'plugins')
|
||||
plugins_conf_dir = config.get('plugins_conf_dir', '')
|
||||
if not plugins_conf_dir:
|
||||
config_home = os.environ.get('XDG_CONFIG_HOME')
|
||||
if not config_home:
|
||||
config_home = os.path.join(os.environ.get('HOME'), '.config')
|
||||
plugins_conf_dir = os.path.join(config_home, 'poezio', 'plugins')
|
||||
plugins_conf_dir = os.path.expanduser(plugins_conf_dir)
|
||||
|
||||
try:
|
||||
os.makedirs(plugins_dir)
|
||||
|
@ -39,6 +42,7 @@ try:
|
|||
os.makedirs(plugins_conf_dir)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
default_plugin_path = path.join(path.dirname(path.dirname(__file__)), 'plugins')
|
||||
|
||||
sys.path.append(default_plugin_path)
|
||||
|
@ -283,3 +287,7 @@ class PluginManager(object):
|
|||
sys.path.remove(plugins_dir)
|
||||
sys.path.append(new_value)
|
||||
plugins_dir = new_value
|
||||
|
||||
def on_plugins_conf_dir_change(self, new_value):
|
||||
global plugins_conf_dir
|
||||
plugins_conf_dir = new_value
|
||||
|
|
Loading…
Reference in a new issue