summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2017-06-20 09:16:12 +0200
committerDave Davenport <qball@gmpclient.org>2017-06-20 17:56:27 +0200
commit8375fbb5136c4aca009afa005d129ba580bf2cdc (patch)
tree9442ff74a3659f169f105899fbf0c657d6c4df3d
parentdc2d85cf9f8d3e41b381be5f6da480d9c250d8b7 (diff)
Support a config.rasi configuration file in the new format
-rw-r--r--lexer/theme-lexer.l4
-rw-r--r--source/rofi.c24
2 files changed, 24 insertions, 4 deletions
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index 19790d93..bf53b0f4 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -307,7 +307,9 @@ if ( queue == NULL ){
yytext[yyleng-1] = '\0';
ParseObject *top = g_queue_peek_head ( file_queue );
g_assert ( top != NULL );
- char *filename = rofi_theme_parse_prepare_file ( &yytext[1], top->filename );
+ char *file2 = helper_get_theme_path ( &yytext[1] );
+ char *filename = rofi_theme_parse_prepare_file ( file2, top->filename );
+ g_free ( file2 );
if ( g_list_find_custom ( imported_files, filename, (GCompareFunc)g_strcmp0 ) != NULL ) {
g_debug ( "Skipping file: '%s' already parsed.", filename );
} else {
diff --git a/source/rofi.c b/source/rofi.c
index f6ab39de..76d1ccc8 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -83,6 +83,7 @@ void rofi_add_error_message ( GString *str )
/** Path to the configuration file */
G_MODULE_EXPORT char *config_path = NULL;
+G_MODULE_EXPORT char *config_path_new = NULL;
/** Array holding all activated modi. */
Mode **modi = NULL;
@@ -321,7 +322,11 @@ static void help ( G_GNUC_UNUSED int argc, char **argv )
printf ( " Support: %s"PACKAGE_URL "%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
printf ( " %s#rofi @ freenode.net%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
if ( find_arg ( "-no-config" ) < 0 ) {
- printf ( " Configuration file: %s%s%s\n", is_term ? color_bold : "", config_path, is_term ? color_reset : "" );
+ if ( config_path_new ) {
+ printf ( " Configuration file: %s%s%s\n", is_term ? color_bold : "", config_path_new, is_term ? color_reset : "" );
+ } else {
+ printf ( " Configuration file: %s%s%s\n", is_term ? color_bold : "", config_path, is_term ? color_reset : "" );
+ }
}
else {
printf ( " Configuration file: %sDisabled%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
@@ -413,6 +418,7 @@ static void cleanup ()
g_free ( modi );
g_free ( config_path );
+ g_free ( config_path_new );
if ( list_of_error_msgs ) {
for ( GList *iter = g_list_first ( list_of_error_msgs );
@@ -766,12 +772,17 @@ int main ( int argc, char *argv[] )
const char *cpath = g_get_user_config_dir ();
if ( cpath ) {
config_path = g_build_filename ( cpath, "rofi", "config", NULL );
+ config_path_new = g_strconcat ( config_path, ".rasi" , NULL );
}
}
else {
char *c = NULL;
find_arg_str ( "-config", &c );
- config_path = rofi_expand_path ( c );
+ if ( g_str_has_suffix ( c, ".rasi" ) ) {
+ config_path_new = rofi_expand_path ( c );
+ } else {
+ config_path = rofi_expand_path ( c );
+ }
}
TICK ();
@@ -811,7 +822,14 @@ int main ( int argc, char *argv[] )
g_free ( etc );
// Load in config from X resources.
config_parse_xresource_options ( xcb );
- config_parse_xresource_options_file ( config_path );
+ if ( config_path_new && g_file_test ( config_path_new, G_FILE_TEST_IS_REGULAR) ) {
+ if ( rofi_theme_parse_file ( config_path_new) ) {
+ rofi_theme_free ( rofi_theme );
+ rofi_theme = NULL;
+ }
+ } else {
+ config_parse_xresource_options_file ( config_path );
+ }
}
find_arg_str ( "-theme", &( config.theme ) );
if ( config.theme ) {