summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2021-06-01 10:43:25 +0200
committerDave Davenport <qball@gmpclient.org>2021-06-01 10:43:25 +0200
commit5a7df38ccdf44117c3b9aa13fc4e951849e738d2 (patch)
tree96d2b653c083cebb729038f0936444861ac024ac /source
parent3cd7170a8d2f97a8d044690795162ff3e6963b1c (diff)
[Configuration] Remove old configuration format.
Diffstat (limited to 'source')
-rw-r--r--source/rofi.c103
-rw-r--r--source/xrmoptions.c89
2 files changed, 5 insertions, 187 deletions
diff --git a/source/rofi.c b/source/rofi.c
index 1603f587..d31d3946 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -95,7 +95,6 @@ void rofi_add_error_message ( GString *str )
/** Path to the configuration file */
G_MODULE_EXPORT char *config_path = NULL;
/** Path to the configuration file in the new format */
-G_MODULE_EXPORT char *config_path_new = NULL;
/** Array holding all activated modi. */
Mode **modi = NULL;
@@ -119,8 +118,6 @@ static int dmenu_mode = FALSE;
/** Rofi's return code */
int return_code = EXIT_SUCCESS;
-/** Flag indicating we are using old config format. */
-static gboolean old_config_format = FALSE;
void process_result ( RofiViewState *state );
@@ -298,7 +295,6 @@ static void print_main_application_options ( int is_term )
print_help_msg ( "-no-plugins", "", "Disable loading of external plugins.", NULL, is_term );
print_help_msg ( "-plugin-path", "", "Directory used to search for rofi plugins. *DEPRECATED*", NULL, is_term );
print_help_msg ( "-dump-config", "", "Dump the current configuration in rasi format and exit.", NULL, is_term );
- print_help_msg ( "-upgrade-config", "", "Upgrade the old-style configuration file in the new rasi format and exit.", NULL, is_term );
print_help_msg ( "-dump-theme", "", "Dump the current theme in rasi format and exit.", NULL, is_term );
}
static void help ( G_GNUC_UNUSED int argc, char **argv )
@@ -350,10 +346,7 @@ 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 @ libera.chat%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
if ( find_arg ( "-no-config" ) < 0 ) {
- if ( config_path_new ) {
- printf ( " Configuration file: %s%s%s\n", is_term ? color_bold : "", config_path_new, is_term ? color_reset : "" );
- }
- else {
+ if ( config_path ) {
printf ( " Configuration file: %s%s%s\n", is_term ? color_bold : "", config_path, is_term ? color_reset : "" );
}
}
@@ -454,7 +447,6 @@ 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 );
@@ -848,19 +840,13 @@ int main ( int argc, char *argv[] )
if ( find_arg ( "-config" ) < 0 ) {
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 );
+ config_path = g_build_filename ( cpath, "rofi", "config.rasi", NULL );
}
}
else {
char *c = NULL;
find_arg_str ( "-config", &c );
- if ( g_str_has_suffix ( c, ".rasi" ) ) {
- config_path_new = rofi_expand_path ( c );
- }
- else {
- config_path = rofi_expand_path ( c );
- }
+ config_path = rofi_expand_path ( c );
}
TICK ();
@@ -908,17 +894,6 @@ int main ( int argc, char *argv[] )
rofi_theme_parse_file ( etc );
found_system = TRUE;
}
- else {
- /** Old format. */
- gchar *xetc = g_build_filename ( dirs[i], "rofi.conf", NULL );
- g_debug ( "Look for default config file: %s", xetc );
- if ( g_file_test ( xetc, G_FILE_TEST_IS_REGULAR ) ) {
- config_parse_xresource_options_file ( xetc );
- old_config_format = TRUE;
- found_system = TRUE;
- }
- g_free ( xetc );
- }
g_free ( etc );
}
}
@@ -930,33 +905,15 @@ int main ( int argc, char *argv[] )
g_debug ( "Look for default config file: %s", etc );
rofi_theme_parse_file ( etc );
}
- else {
- /** Old format. */
- gchar *xetc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
- g_debug ( "Look for default config file: %s", xetc );
- if ( g_file_test ( xetc, G_FILE_TEST_IS_REGULAR ) ) {
- config_parse_xresource_options_file ( xetc );
- old_config_format = TRUE;
- }
- g_free ( xetc );
- }
g_free ( etc );
}
- if ( config_path_new && g_file_test ( config_path_new, G_FILE_TEST_IS_REGULAR ) ) {
- if ( rofi_theme_parse_file ( config_path_new ) ) {
+ if ( config_path && g_file_test ( config_path, G_FILE_TEST_IS_REGULAR ) ) {
+ if ( rofi_theme_parse_file ( config_path ) ) {
rofi_theme_free ( rofi_theme );
rofi_theme = NULL;
}
}
- else {
- g_free ( config_path_new );
- config_path_new = NULL;
- if ( g_file_test ( config_path, G_FILE_TEST_IS_REGULAR ) ) {
- config_parse_xresource_options_file ( config_path );
- old_config_format = TRUE;
- }
- }
}
find_arg_str ( "-theme", &( config.theme ) );
if ( config.theme ) {
@@ -972,10 +929,6 @@ int main ( int argc, char *argv[] )
config_parse_cmd_options ( );
TICK_N ( "Load cmd config " );
- if ( old_config_format ) {
- g_warning ( "The old Xresources based configuration format is deprecated." );
- g_warning ( "Please upgrade: rofi -upgrade-config." );
- }
parse_keys_abe ( bindings );
// Get the path to the cache dir.
@@ -1052,52 +1005,6 @@ int main ( int argc, char *argv[] )
cleanup ();
return EXIT_SUCCESS;
}
- if ( find_arg ( "-upgrade-config" ) >= 0 ) {
- setup_modi ();
-
- for ( unsigned int i = 0; i < num_modi; i++ ) {
- mode_init ( modi[i] );
- }
-
- const char *cpath = g_get_user_config_dir ();
- if ( cpath ) {
- char *fcpath = g_build_filename ( cpath, "rofi", NULL );
- if ( !g_file_test ( fcpath, G_FILE_TEST_IS_DIR ) && g_mkdir_with_parents ( fcpath, 0700 ) < 0 ) {
- g_warning ( "Failed to create rofi configuration directory: %s", fcpath );
- cleanup ();
- g_free ( fcpath );
- return EXIT_FAILURE;
- }
- g_free ( fcpath );
- fcpath = g_build_filename ( cpath, "rofi", "config.rasi", NULL );
- if ( g_file_test ( fcpath, G_FILE_TEST_IS_REGULAR ) ) {
- g_warning ( "New configuration file already exists: %s", fcpath );
- cleanup ();
- g_free ( fcpath );
- return EXIT_FAILURE;
- }
- FILE *fd = fopen ( fcpath, "w" );
- if ( fd == NULL ) {
- g_warning ( "Failed to open new rofi configuration file: %s: %s", fcpath, strerror ( errno ) );
- cleanup ();
- g_free ( fcpath );
- return EXIT_FAILURE;
- }
- config_parse_dump_config_rasi_format ( fd, TRUE );
- fprintf ( stdout, "\n***** Generated configuration file in: %s *****\n", fcpath );
-
- fflush ( fd );
- fclose ( fd );
- g_free ( fcpath );
- }
- else {
- g_warning ( "Failed to get user configuration directory." );
- cleanup ();
- return EXIT_FAILURE;
- }
- cleanup ();
- return EXIT_SUCCESS;
- }
if ( find_arg ( "-dump-config" ) >= 0 ) {
config_parse_dump_config_rasi_format ( stdout, FALSE );
cleanup ();
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index b597decc..db1b1c07 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -32,7 +32,6 @@
#include <unistd.h>
#include <xcb/xcb.h>
#include <xcb/xkb.h>
-#include <xcb/xcb_xrm.h>
#include <glib.h>
#include "xcb.h"
#include "xcb-internal.h"
@@ -260,94 +259,6 @@ void config_parser_add_option ( XrmOptionType type, const char *key, void **valu
num_extra_options++;
}
-static void config_parser_set ( XrmOption *option, char *xrmValue, enum ConfigSource source )
-{
- switch ( option->type )
- {
- case xrm_String:
- if ( ( option )->mem != NULL ) {
- g_free ( option->mem );
- option->mem = NULL;
- }
- *( option->value.str ) = g_strchomp ( g_strdup ( xrmValue ) );
-
- // Memory
- ( option )->mem = *( option->value.str );
- break;
- case xrm_Number:
- *( option->value.num ) = (unsigned int) g_ascii_strtoull ( xrmValue, NULL, 10 );
- break;
- case xrm_SNumber:
- *( option->value.snum ) = (int) g_ascii_strtoll ( xrmValue, NULL, 10 );
- break;
- case xrm_Boolean:
- if ( strlen ( xrmValue ) > 0 &&
- g_ascii_strcasecmp ( xrmValue, "true" ) == 0 ) {
- *( option->value.num ) = TRUE;
- }
- else{
- *( option->value.num ) = FALSE;
- }
- break;
- case xrm_Char:
- *( option->value.charc ) = helper_parse_char ( xrmValue );
- break;
- }
- option->source = source;
-}
-
-static void __config_parse_xresource_options ( xcb_xrm_database_t *xDB, enum ConfigSource source )
-{
- const char * namePrefix = "rofi";
-
- for ( unsigned int i = 0; i < sizeof ( xrmOptions ) / sizeof ( XrmOption ); ++i ) {
- char *name = g_strdup_printf ( "%s.%s", namePrefix, xrmOptions[i].name );
-
- char *xrmValue = NULL;
- if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) {
- config_parser_set ( &( xrmOptions[i] ), xrmValue, source );
- }
- if ( xrmValue ) {
- free ( xrmValue );
- }
-
- g_free ( name );
- }
-}
-static void __config_parse_xresource_options_dynamic ( xcb_xrm_database_t *xDB, enum ConfigSource source )
-{
- const char * namePrefix = "rofi";
-
- for ( unsigned int i = 0; i < num_extra_options; ++i ) {
- char *name;
-
- name = g_strdup_printf ( "%s.%s", namePrefix, extra_options[i].name );
- char *xrmValue = NULL;
- if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) {
- config_parser_set ( &( extra_options[i] ), xrmValue, source );
- }
- if ( xrmValue ) {
- free ( xrmValue );
- }
-
- g_free ( name );
- }
-}
-
-void config_parse_xresource_options_file ( const char *filename )
-{
- if ( !filename ) {
- return;
- }
- // Map Xresource entries to rofi config options.
- xcb_xrm_database_t *xDB = xcb_xrm_database_from_file ( filename );
- if ( xDB == NULL ) {
- return;
- }
- __config_parse_xresource_options ( xDB, CONFIG_FILE );
- __config_parse_xresource_options_dynamic ( xDB, CONFIG_FILE );
- xcb_xrm_database_free ( xDB );
-}
/**
* Parse an option from the commandline vector.