summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2008-03-11 14:52:57 +0100
committerSebastien Helleu <flashcode@flashtux.org>2008-03-11 14:52:57 +0100
commit469ff93d915ad5c20a5c3577c1cf92c5f1fad0f1 (patch)
tree3edcff5fcaa09375ce773e85eab3ee10dd07be04 /src
parent24ea547090117d887e29f569dbb06cfcf57a5c64 (diff)
downloadweechat-469ff93d915ad5c20a5c3577c1cf92c5f1fad0f1.zip
Added "startup" section in config, new options "startup_command_{before|after}_plugins"
Diffstat (limited to 'src')
-rw-r--r--src/core/wee-command.c30
-rw-r--r--src/core/wee-command.h1
-rw-r--r--src/core/wee-config.c49
-rw-r--r--src/core/wee-config.h7
-rw-r--r--src/core/weechat.c14
5 files changed, 81 insertions, 20 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index efcf84573..c622bad9d 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -2217,6 +2217,36 @@ command_init ()
}
/*
+ * command_startup: execute command at startup
+ */
+
+void
+command_startup (int plugins_loaded)
+{
+ char *command, **commands, **ptr_cmd;
+ struct t_gui_buffer *weechat_buffer;
+
+ if (plugins_loaded)
+ command = CONFIG_STRING(config_startup_command_before_plugins);
+ else
+ command = CONFIG_STRING(config_startup_command_after_plugins);
+
+ if (command && command[0])
+ {
+ commands = string_split_command (command, ';');
+ if (commands)
+ {
+ weechat_buffer = gui_buffer_search_main ();
+ for (ptr_cmd = commands; *ptr_cmd; ptr_cmd++)
+ {
+ input_data (weechat_buffer, *ptr_cmd, 0);
+ }
+ string_free_splitted_command (commands);
+ }
+ }
+}
+
+/*
* command_print_stdout: print list of commands on standard output
*/
diff --git a/src/core/wee-command.h b/src/core/wee-command.h
index f73e06fc7..ad03dcfc2 100644
--- a/src/core/wee-command.h
+++ b/src/core/wee-command.h
@@ -25,6 +25,7 @@ struct t_gui_buffer;
extern int command_reload (void *data, struct t_gui_buffer *buffer,
int argc, char **argv, char **argv_eol);
extern void command_init ();
+extern void command_startup (int plugins_looaded);
extern void command_print_stdout ();
#endif /* wee-command.h */
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 17f475227..5d8838dc3 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -56,13 +56,18 @@
struct t_config_file *weechat_config_file = NULL;
+/* config, startup section */
+
+struct t_config_option *config_startup_logo;
+struct t_config_option *config_startup_version;
+struct t_config_option *config_startup_command_before_plugins;
+struct t_config_option *config_startup_command_after_plugins;
+
/* config, look & feel section */
struct t_config_option *config_look_color_real_white;
struct t_config_option *config_look_save_on_exit;
struct t_config_option *config_look_set_title;
-struct t_config_option *config_look_startup_logo;
-struct t_config_option *config_look_startup_version;
struct t_config_option *config_look_weechat_slogan;
struct t_config_option *config_look_scroll_amount;
struct t_config_option *config_look_buffer_time_format;
@@ -588,6 +593,36 @@ config_weechat_init ()
if (!weechat_config_file)
return 0;
+ /* startup */
+ ptr_section = config_file_new_section (weechat_config_file, "startup",
+ NULL, NULL, NULL, NULL, NULL, NULL);
+ if (!ptr_section)
+ {
+ config_file_free (weechat_config_file);
+ return 0;
+ }
+
+ config_startup_logo = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "startup_logo", "boolean",
+ N_("display WeeChat logo at startup"),
+ NULL, 0, 0, "on", NULL, NULL);
+ config_startup_version = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "startup_version", "boolean",
+ N_("display WeeChat version at startup"),
+ NULL, 0, 0, "on", NULL, NULL);
+ config_startup_command_before_plugins = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "startup_command_before_plugins", "string",
+ N_("command executed when WeeChat starts, before loading plugins"),
+ NULL, 0, 0, "", NULL, NULL);
+ config_startup_command_after_plugins = config_file_new_option (
+ weechat_config_file, ptr_section,
+ "startup_command_after_plugins", "string",
+ N_("command executed when WeeChat starts, after loading plugins"),
+ NULL, 0, 0, "", NULL, NULL);
+
/* look */
ptr_section = config_file_new_section (weechat_config_file, "look",
NULL, NULL, NULL, NULL, NULL, NULL);
@@ -617,16 +652,6 @@ config_weechat_init ()
N_("set title for window (terminal for Curses GUI) with "
"name and version"),
NULL, 0, 0, "on", &config_change_title, NULL);
- config_look_startup_logo = config_file_new_option (
- weechat_config_file, ptr_section,
- "look_startup_logo", "boolean",
- N_("display WeeChat logo at startup"),
- NULL, 0, 0, "on", NULL, NULL);
- config_look_startup_version = config_file_new_option (
- weechat_config_file, ptr_section,
- "look_startup_version", "boolean",
- N_("display WeeChat version at startup"),
- NULL, 0, 0, "on", NULL, NULL);
config_look_weechat_slogan = config_file_new_option (
weechat_config_file, ptr_section,
"look_weechat_slogan", "string",
diff --git a/src/core/wee-config.h b/src/core/wee-config.h
index 910ab4db7..fcd464b0c 100644
--- a/src/core/wee-config.h
+++ b/src/core/wee-config.h
@@ -42,11 +42,14 @@
extern struct t_config_file *weechat_config_file;
+extern struct t_config_option *config_startup_logo;
+extern struct t_config_option *config_startup_version;
+extern struct t_config_option *config_startup_command_before_plugins;
+extern struct t_config_option *config_startup_command_after_plugins;
+
extern struct t_config_option *config_look_color_real_white;
extern struct t_config_option *config_look_save_on_exit;
extern struct t_config_option *config_look_set_title;
-extern struct t_config_option *config_look_startup_logo;
-extern struct t_config_option *config_look_startup_version;
extern struct t_config_option *config_look_weechat_slogan;
extern struct t_config_option *config_look_one_server_buffer;
extern struct t_config_option *config_look_open_near_server;
diff --git a/src/core/weechat.c b/src/core/weechat.c
index c98a3a4a0..3dd42e587 100644
--- a/src/core/weechat.c
+++ b/src/core/weechat.c
@@ -410,7 +410,7 @@ weechat_init_vars ()
void
weechat_welcome_message ()
{
- if (CONFIG_BOOLEAN(config_look_startup_logo))
+ if (CONFIG_BOOLEAN(config_startup_logo))
{
gui_chat_printf (NULL,
"%s ___ __ ______________ _____ \n"
@@ -428,27 +428,27 @@ weechat_welcome_message ()
&& CONFIG_STRING(config_look_weechat_slogan)[0])
{
gui_chat_printf (NULL, _("%sWelcome to %s%s%s, %s"),
- (CONFIG_BOOLEAN(config_look_startup_logo)) ?
+ (CONFIG_BOOLEAN(config_startup_logo)) ?
" " : "",
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
PACKAGE_NAME,
GUI_NO_COLOR,
CONFIG_STRING(config_look_weechat_slogan));
}
- if (CONFIG_BOOLEAN(config_look_startup_version))
+ if (CONFIG_BOOLEAN(config_startup_version))
{
gui_chat_printf (NULL, "%s%s%s%s, %s %s %s",
- (CONFIG_BOOLEAN(config_look_startup_logo)) ?
+ (CONFIG_BOOLEAN(config_startup_logo)) ?
" " : "",
GUI_COLOR(GUI_COLOR_CHAT_BUFFER),
PACKAGE_STRING,
GUI_NO_COLOR,
_("compiled on"), __DATE__, __TIME__);
}
- if (CONFIG_BOOLEAN(config_look_startup_logo) ||
+ if (CONFIG_BOOLEAN(config_startup_logo) ||
(CONFIG_STRING(config_look_weechat_slogan)
&& CONFIG_STRING(config_look_weechat_slogan)[0]) ||
- CONFIG_BOOLEAN(config_look_startup_version))
+ CONFIG_BOOLEAN(config_startup_version))
gui_chat_printf (NULL,
"%s-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-",
GUI_COLOR(GUI_COLOR_CHAT_NICK));
@@ -521,7 +521,9 @@ main (int argc, char *argv[])
//if (weechat_session)
//session_load (weechat_session); /* load previous session if asked */
weechat_welcome_message (); /* display WeeChat welcome message */
+ command_startup (0); /* command executed before plugins */
plugin_init (auto_load_plugins); /* init plugin interface(s) */
+ command_startup (1); /* command executed after plugins */
gui_main_loop (); /* WeeChat main loop */
plugin_end (); /* end plugin interface(s) */
if (CONFIG_BOOLEAN(config_look_save_on_exit))