summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-04-01 17:58:41 +0200
committerDave Davenport <qball@gmpclient.org>2016-04-01 17:58:41 +0200
commit1b4e5069f6ed11a9b75252458d892050b9c8c197 (patch)
tree9aa57a5be2d82a62e70b7971fc6e1fffc35073d8
parent0c7d1a6b177727384efb4b0479b9aceb279d1cdd (diff)
Revert "Test config file before load, support ~/.config/rofi/theme and remove config_path global, fix loading dynamic options from /etc/rofi.conf"
-rw-r--r--include/mode.h2
-rw-r--r--include/textbox.h18
-rw-r--r--source/rofi.c64
3 files changed, 38 insertions, 46 deletions
diff --git a/include/mode.h b/include/mode.h
index aaf38566..90bae0f3 100644
--- a/include/mode.h
+++ b/include/mode.h
@@ -7,7 +7,7 @@
* The 'object' that makes a mode in rofi.
* @{
*/
-typedef struct rofi_mode Mode;
+typedef struct rofi_mode Mode;
/**
* Enum used to sum the possible states of ROFI.
diff --git a/include/textbox.h b/include/textbox.h
index e1d608e1..3d3b8d09 100644
--- a/include/textbox.h
+++ b/include/textbox.h
@@ -38,15 +38,15 @@ typedef struct
typedef enum
{
- TB_AUTOHEIGHT = 1 << 0,
- TB_AUTOWIDTH = 1 << 1,
- TB_LEFT = 1 << 16,
- TB_RIGHT = 1 << 17,
- TB_CENTER = 1 << 18,
- TB_EDITABLE = 1 << 19,
- TB_MARKUP = 1 << 20,
- TB_WRAP = 1 << 21,
- TB_PASSWORD = 1 << 22,
+ TB_AUTOHEIGHT = 1 << 0,
+ TB_AUTOWIDTH = 1 << 1,
+ TB_LEFT = 1 << 16,
+ TB_RIGHT = 1 << 17,
+ TB_CENTER = 1 << 18,
+ TB_EDITABLE = 1 << 19,
+ TB_MARKUP = 1 << 20,
+ TB_WRAP = 1 << 21,
+ TB_PASSWORD = 1 << 22,
} TextboxFlags;
typedef enum
diff --git a/source/rofi.c b/source/rofi.c
index 07fda651..0b5618f6 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -78,6 +78,7 @@ struct xkb_stuff xkb = {
.state = NULL
}
};
+char *config_path = NULL;
// Array of modi.
Mode **modi = NULL;
unsigned int num_modi = 0;
@@ -336,6 +337,8 @@ static void cleanup ()
// Cleanup the custom keybinding
cleanup_abe ();
+ g_free ( config_path );
+
TIMINGS_STOP ();
}
@@ -430,51 +433,24 @@ static void setup_modi ( void )
*/
static inline void load_configuration ( )
{
- const char *cpath = g_get_user_config_dir ();
- char *config_path = NULL;
// Load distro default settings
- gchar *etc = g_build_filename ( G_DIR_SEPARATOR_S, "etc", "rofi.conf", NULL );
+ gchar *etc = g_build_filename ( G_DIR_SEPARATOR_S, "etc", "rofi.conf", NULL );
if ( g_file_test ( etc, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR ) ) {
config_parse_xresource_options_file ( etc );
- config_parse_xresource_options_dynamic_file ( etc );
}
g_free ( etc );
-
// Load in config from X resources.
config_parse_xresource_options ( xcb );
- config_parse_xresource_options_dynamic ( xcb );
-
- if ( find_arg ( "-config" ) < 0 ) {
- if ( cpath ) {
- config_path = g_build_filename ( cpath, "rofi", "config", NULL );
- }
- }
- else {
- char *c = NULL;
- find_arg_str ( "-config", &c );
- config_path = rofi_expand_path ( c );
- }
- if ( config_path != NULL ) {
- if ( g_file_test ( config_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR ) ) {
- // Load config from config file.
- config_parse_xresource_options_file ( config_path );
- config_parse_xresource_options_dynamic_file ( config_path );
- }
- g_free ( config_path );
- }
-
- // Load theme file
- if ( cpath ) {
- char *theme_path = g_build_filename ( cpath, "rofi", "theme", NULL );
- if ( g_file_test ( theme_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR ) ) {
- config_parse_xresource_options_file ( theme_path );
- config_parse_xresource_options_dynamic_file ( theme_path );
- }
- g_free ( theme_path );
- }
+ config_parse_xresource_options_file ( config_path );
// Parse command line for settings.
config_parse_cmd_options ( );
+}
+static inline void load_configuration_dynamic ( )
+{
+ // Load in config from X resources.
+ config_parse_xresource_options_dynamic ( xcb );
+ config_parse_xresource_options_dynamic_file ( config_path );
config_parse_cmd_options_dynamic ( );
}
@@ -667,6 +643,18 @@ int main ( int argc, char *argv[] )
}
config_parser_add_option ( xrm_String, "pid", (void * *) &pidfile, "Pidfile location" );
+ if ( find_arg ( "-config" ) < 0 ) {
+ const char *cpath = g_get_user_config_dir ();
+ if ( cpath ) {
+ config_path = g_build_filename ( cpath, "rofi", "config", NULL );
+ }
+ }
+ else {
+ char *c = NULL;
+ find_arg_str ( "-config", &c );
+ config_path = rofi_expand_path ( c );
+ }
+
TICK ();
// Register cleanup function.
atexit ( cleanup );
@@ -818,6 +806,9 @@ int main ( int argc, char *argv[] )
setup_abe ();
TICK_N ( "Setup abe" );
+ if ( find_arg ( "-no-config" ) < 0 ) {
+ load_configuration ( );
+ }
if ( !dmenu_mode ) {
// setup_modi
setup_modi ();
@@ -827,7 +818,8 @@ int main ( int argc, char *argv[] )
config_parser_add_option ( xrm_Char, "sep", (void * *) &( config.separator ), "Element separator" );
}
if ( find_arg ( "-no-config" ) < 0 ) {
- load_configuration ( );
+ // Reload for dynamic part.
+ load_configuration_dynamic ( );
}
// Dump.
// catch help request