about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/config/theme.c8
-rw-r--r--src/main.c5
-rw-r--r--src/profanity.c23
-rw-r--r--src/profanity.h2
4 files changed, 27 insertions, 11 deletions
diff --git a/src/config/theme.c b/src/config/theme.c
index eafd431c..c7d979c5 100644
--- a/src/config/theme.c
+++ b/src/config/theme.c
@@ -67,8 +67,12 @@ static gboolean _theme_load_file(const char *const theme_name);
 void
 theme_init(const char *const theme_name)
 {
-    if (!_theme_load_file(theme_name) && !_theme_load_file("default")) {
-        log_error("Theme initialisation failed");
+    if (!_theme_load_file(theme_name)) {
+        log_error("Loading theme %s failed.", theme_name);
+
+        if (!_theme_load_file("default")) {
+            log_error("Theme initialisation failed.");
+        }
     }
 
     defaults = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
diff --git a/src/main.c b/src/main.c
index 65f69966..f87e8866 100644
--- a/src/main.c
+++ b/src/main.c
@@ -64,6 +64,7 @@ static char *log = NULL;
 static char *log_file = NULL;
 static char *account_name = NULL;
 static char *config_file = NULL;
+static char *theme_name = NULL;
 
 int
 main(int argc, char **argv)
@@ -80,6 +81,7 @@ main(int argc, char **argv)
         { "log", 'l', 0, G_OPTION_ARG_STRING, &log, "Set logging levels, DEBUG, INFO (default), WARN, ERROR", "LEVEL" },
         { "config", 'c', 0, G_OPTION_ARG_STRING, &config_file, "Use an alternative configuration file", NULL },
         { "logfile", 'f', 0, G_OPTION_ARG_STRING, &log_file, "Specify log filename", NULL },
+        { "theme", 't', 0, G_OPTION_ARG_STRING, &theme_name, "Specify theme name", NULL },
         { NULL }
     };
 
@@ -175,13 +177,14 @@ main(int argc, char **argv)
         return 0;
     }
 
-    prof_run(log ? log : "INFO", account_name, config_file, log_file);
+    prof_run(log ? log : "INFO", account_name, config_file, log_file, theme_name);
 
     /* Free resources allocated by GOptionContext */
     g_free(log);
     g_free(account_name);
     g_free(config_file);
     g_free(log_file);
+    g_free(theme_name);
 
     return 0;
 }
diff --git a/src/profanity.c b/src/profanity.c
index 68b20aff..dc7bf954 100644
--- a/src/profanity.c
+++ b/src/profanity.c
@@ -86,7 +86,7 @@
 #include "omemo/omemo.h"
 #endif
 
-static void _init(char *log_level, char *config_file, char *log_file);
+static void _init(char *log_level, char *config_file, char *log_file, char *theme_name);
 static void _shutdown(void);
 static void _connect_default(const char * const account);
 
@@ -94,9 +94,9 @@ static gboolean cont = TRUE;
 static gboolean force_quit = FALSE;
 
 void
-prof_run(char *log_level, char *account_name, char *config_file, char *log_file)
+prof_run(char *log_level, char *account_name, char *config_file, char *log_file, char *theme_name)
 {
-    _init(log_level, config_file, log_file);
+    _init(log_level, config_file, log_file, theme_name);
     plugins_on_start();
     _connect_default(account_name);
 
@@ -157,7 +157,7 @@ _connect_default(const char *const account)
 }
 
 static void
-_init(char *log_level, char *config_file, char *log_file)
+_init(char *log_level, char *config_file, char *log_file, char *theme_name)
 {
     setlocale(LC_ALL, "");
     // ignore SIGPIPE
@@ -169,12 +169,14 @@ _init(char *log_level, char *config_file, char *log_file)
         log_error("Mutex init failed");
         exit(1);
     }
+
     pthread_mutex_lock(&lock);
     files_create_directories();
     log_level_t prof_log_level = log_level_from_string(log_level);
     prefs_load(config_file);
     log_init(prof_log_level, log_file);
     log_stderr_init(PROF_LEVEL_ERROR);
+
     if (strcmp(PACKAGE_STATUS, "development") == 0) {
 #ifdef HAVE_GIT_VERSION
             log_info("Starting Profanity (%sdev.%s.%s)...", PACKAGE_VERSION, PROF_GIT_BRANCH, PROF_GIT_REVISION);
@@ -184,12 +186,19 @@ _init(char *log_level, char *config_file, char *log_file)
     } else {
         log_info("Starting Profanity (%s)...", PACKAGE_VERSION);
     }
+
     chat_log_init();
     groupchat_log_init();
     accounts_load();
-    char *theme = prefs_get_string(PREF_THEME);
-    theme_init(theme);
-    prefs_free_string(theme);
+
+    if (theme_name) {
+        theme_init(theme_name);
+    } else {
+        char *theme = prefs_get_string(PREF_THEME);
+        theme_init(theme);
+        prefs_free_string(theme);
+    }
+
     ui_init();
     session_init();
     cmd_init();
diff --git a/src/profanity.h b/src/profanity.h
index 44a116e8..040a897a 100644
--- a/src/profanity.h
+++ b/src/profanity.h
@@ -40,7 +40,7 @@
 #include <pthread.h>
 #include <glib.h>
 
-void prof_run(char *log_level, char *account_name, char *config_file, char *log_file);
+void prof_run(char *log_level, char *account_name, char *config_file, char *log_file, char *theme_name);
 void prof_set_quit(void);
 
 pthread_mutex_t lock;