From 420d1748e730c80fba212c27ea2f693e37fae6c8 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Wed, 2 Dec 2020 21:54:49 +0100 Subject: Remove Xresources. --- configure.ac | 2 +- doc/rofi.1 | 48 +--------------- doc/rofi.1.markdown | 24 +------- include/xrmoptions.h | 17 ------ meson.build | 1 - source/rofi.c | 38 ------------- source/xrmoptions.c | 153 --------------------------------------------------- 7 files changed, 3 insertions(+), 280 deletions(-) diff --git a/configure.ac b/configure.ac index e0968b65..9eaefae6 100644 --- a/configure.ac +++ b/configure.ac @@ -144,7 +144,7 @@ NK_INIT([bindings xdg-theme]) PKG_CHECK_MODULES([glib], [glib-2.0 >= ${glib_min_version} gio-unix-2.0 gmodule-2.0]) AC_DEFINE_UNQUOTED([GLIB_VERSION_MIN_REQUIRED], [(G_ENCODE_VERSION(${glib_min_major},${glib_min_minor}))], [The lower GLib version supported]) AC_DEFINE_UNQUOTED([GLIB_VERSION_MAX_ALLOWED], [(G_ENCODE_VERSION(${glib_min_major},${glib_min_minor}))], [The highest GLib version supported]) -GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon xkbcommon-x11 xcb-ewmh xcb-icccm xcb-xrm xcb-randr xcb-xinerama]) +GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon xkbcommon-x11 xcb-ewmh xcb-icccm xcb-randr xcb-xinerama]) PKG_CHECK_MODULES([pango], [pango pangocairo]) PKG_CHECK_MODULES([cairo], [cairo cairo-xcb]) PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0 ]) diff --git a/doc/rofi.1 b/doc/rofi.1 index 1cc3f806..a086b85c 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -76,24 +76,12 @@ System configuration file (for example \fB\fC/etc/rofi.rasi\fR or old format \f It first checks XDG\_CONFIG\_DIRS and then SYSCONFDIR (that is passed at compile time). It loads the first config file it finds, it does not merge multiple system configuration files. .IP \(bu 2 -Xresources: A method of storing key values in the Xserver. See -here -\[la]https://en.wikipedia.org/wiki/X_resources\[ra] for more information. -.IP \(bu 2 Rasi theme file: The new \fItheme\fP format can be used to set configuration values. .IP \(bu 2 -Configuration File: This uses the same format as the Xresources file. -By default it looks in \fB\fCXDG\_CONFIG\_HOME\fR/rofi/config, but can be overridden on commandline. -By default \fB\fCXDG\_CONFIG\_HOME\fR defaults to \fB\fC$HOME/.config\fR\&. (See \fB\fCrofi \-h\fR for current location). -This is the recommended way of configuring \fBrofi\fP\&. -.IP \(bu 2 Command\-line options: Arguments passed to \fBrofi\fP\&. .RE -.PP -\fBTIP\fP: To get a template config file run: \fB\fCrofi \-dump\-xresources > rofi\-example.config\fR\&. - .PP \fBNOTE\fP: In version 1.4.0 we support configuration in a new format, a config for this can be generated by: \fB\fCrofi \-dump\-config > config.rasi\fR @@ -102,22 +90,7 @@ Command\-line options: Arguments passed to \fBrofi\fP\&. \fBNOTE\fP: If you want to use the new configuration format, the config file should be named \fB\fCconfig.rasi\fR\&. .PP -\fBNOTE\fP: You can upgrade to the new configuration file format using \fB\fCrofi \-upgrade\-config\fR - -.PP -The Xresources file expects options starting with \fB\fCrofi.\fR followed by its name. An example to set the number of lines: - -.PP -.RS - -.nf -rofi.lines: 10 - -.fi -.RE - -.PP -Command\-line options override settings from the Xresources file. The same option set as argument — prefixed with a '\-': +Command\-line options override settings from the file. The same option set as argument — prefixed with a '\-': .PP .RS @@ -128,18 +101,6 @@ rofi \-lines 10 .fi .RE -.PP -To get a list of available options formatted as Xresources entries, run: - -.PP -.RS - -.nf -rofi \-dump\-xresources - -.fi -.RE - .PP The configuration system supports the following types: @@ -209,13 +170,6 @@ Information about the rasi format can be found in the \fBrofi\-theme(5)\fP manpa .PP Dump the current active theme, in rasi format, to stdout and exit. -.PP -\fB\fC\-dump\-xresources\fR - -.PP -Dump the current active configuration, in Xresources format, to stdout. -This does not validate all passed values (for example, colors). - .PP \fB\fC\-threads\fR \fInum\fP diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index 7f55d266..b0148f69 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -56,36 +56,19 @@ There are currently three methods of setting configuration options (evaluated in * System configuration file (for example `/etc/rofi.rasi` or old format `/etc/rofi.conf`). It first checks XDG_CONFIG_DIRS and then SYSCONFDIR (that is passed at compile time). It loads the first config file it finds, it does not merge multiple system configuration files. - * Xresources: A method of storing key values in the Xserver. See - [here](https://en.wikipedia.org/wiki/X_resources) for more information. * Rasi theme file: The new *theme* format can be used to set configuration values. - * Configuration File: This uses the same format as the Xresources file. - By default it looks in `XDG_CONFIG_HOME`/rofi/config, but can be overridden on commandline. - By default `XDG_CONFIG_HOME` defaults to `$HOME/.config`. (See `rofi -h` for current location). - This is the recommended way of configuring **rofi**. * Command-line options: Arguments passed to **rofi**. -**TIP**: To get a template config file run: `rofi -dump-xresources > rofi-example.config`. **NOTE**: In version 1.4.0 we support configuration in a new format, a config for this can be generated by: `rofi -dump-config > config.rasi` **NOTE**: If you want to use the new configuration format, the config file should be named `config.rasi`. -**NOTE**: You can upgrade to the new configuration file format using `rofi -upgrade-config` - -The Xresources file expects options starting with `rofi.` followed by its name. An example to set the number of lines: - - rofi.lines: 10 - -Command-line options override settings from the Xresources file. The same option set as argument — prefixed with a '-': +Command-line options override settings from the file. The same option set as argument — prefixed with a '-': rofi -lines 10 -To get a list of available options formatted as Xresources entries, run: - - rofi -dump-xresources - The configuration system supports the following types: * string @@ -123,11 +106,6 @@ Information about the rasi format can be found in the **rofi-theme(5)** manpage. Dump the current active theme, in rasi format, to stdout and exit. -`-dump-xresources` - -Dump the current active configuration, in Xresources format, to stdout. -This does not validate all passed values (for example, colors). - `-threads` *num* Specify the number of threads **rofi** should use: diff --git a/include/xrmoptions.h b/include/xrmoptions.h index 573ad810..12da3997 100644 --- a/include/xrmoptions.h +++ b/include/xrmoptions.h @@ -80,23 +80,6 @@ typedef enum xrm_Char = 4 } XrmOptionType; -/** - * @param xcb Handler object holding connection used to fetch the settings from. - * - * Parse the rofi related X resource options of the - * connected X server. - * - * @ingroup CONFXServer - */ -void config_parse_xresource_options ( xcb_stuff *xcb ); - -/** - * @param filename The xresources file to parse - * - * Parses filename and updates the config - * @ingroup CONFFile - */ -void config_parse_xresource_options_file ( const char *filename ); /** * Parse commandline options. diff --git a/meson.build b/meson.build index 265b3074..3b71ce30 100644 --- a/meson.build +++ b/meson.build @@ -60,7 +60,6 @@ deps += [ dependency('xkbcommon-x11'), dependency('xcb-ewmh'), dependency('xcb-icccm'), - dependency('xcb-xrm'), dependency('xcb-randr'), dependency('xcb-xinerama'), dependency('cairo-xcb'), diff --git a/source/rofi.c b/source/rofi.c index b50a69ef..426e9a41 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -289,7 +289,6 @@ static void print_main_application_options ( int is_term ) print_help_msg ( "-dmenu", "", "Start in dmenu mode.", NULL, is_term ); print_help_msg ( "-display", "[string]", "X server to contact.", "${DISPLAY}", is_term ); print_help_msg ( "-h,-help", "", "This help message.", NULL, is_term ); - print_help_msg ( "-dump-xresources", "", "Dump the current configuration in Xresources format and exit.", NULL, is_term ); print_help_msg ( "-e", "[string]", "Show a dialog displaying the passed message and exit.", NULL, is_term ); print_help_msg ( "-markup", "", "Enable pango markup where possible.", NULL, is_term ); print_help_msg ( "-normal-window", "", "Behave as a normal window. (experimental)", NULL, is_term ); @@ -450,7 +449,6 @@ static void cleanup () nk_bindings_free ( bindings ); // Cleaning up memory allocated by the Xresources file. - config_xresource_free (); g_free ( modi ); g_free ( config_path ); @@ -900,17 +898,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 ); } } @@ -922,20 +909,8 @@ 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 ); } - // Load in config from X resources. - config_parse_xresource_options ( xcb ); if ( config_path_new && g_file_test ( config_path_new, G_FILE_TEST_IS_REGULAR ) ) { if ( rofi_theme_parse_file ( config_path_new ) ) { @@ -943,14 +918,6 @@ int main ( int argc, char *argv[] ) 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 ) { @@ -1103,11 +1070,6 @@ int main ( int argc, char *argv[] ) cleanup (); return EXIT_SUCCESS; } - if ( find_arg ( "-dump-xresources" ) >= 0 ) { - config_parse_xresource_dump (); - cleanup (); - return EXIT_SUCCESS; - } unsigned int interval = 1; if ( find_arg_uint ( "-record-screenshots", &interval ) ) { diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 95127e4e..48e0b39c 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include "xcb.h" #include "xcb-internal.h" @@ -209,102 +208,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 ( xcb_stuff *xcb ) -{ - xcb_xrm_database_t *xDB = xcb_xrm_database_from_default ( xcb->connection ); - if ( xDB ) { - __config_parse_xresource_options ( xDB, CONFIG_XRESOURCES ); - __config_parse_xresource_options_dynamic ( xDB, CONFIG_XRESOURCES ); - xcb_xrm_database_free ( xDB ); - } -} -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. @@ -481,62 +384,6 @@ void config_xresource_free ( void ) } } -static void xresource_dump_entry ( const char *namePrefix, XrmOption *option ) -{ - printf ( "! \"%s\" ", option->comment ); - printf ( "Set from: %s\n", ConfigSourceStr[option->source] ); - if ( option->source == CONFIG_DEFAULT ) { - printf ( "! " ); - } - printf ( "%s.%s: %*s", namePrefix, option->name, - (int) ( 30 - strlen ( option->name ) ), "" ); - switch ( option->type ) - { - case xrm_Number: - printf ( "%u", *( option->value.num ) ); - break; - case xrm_SNumber: - printf ( "%i", *( option->value.snum ) ); - break; - case xrm_String: - if ( ( *( option->value.str ) ) != NULL ) { - printf ( "%s", *( option->value.str ) ); - } - break; - case xrm_Boolean: - printf ( "%s", ( *( option->value.num ) == TRUE ) ? "true" : "false" ); - break; - case xrm_Char: - if ( *( option->value.charc ) > 32 && *( option->value.charc ) < 127 ) { - printf ( "%c", *( option->value.charc ) ); - } - else { - printf ( "\\x%02X", *( option->value.charc ) ); - } - break; - default: - break; - } - printf ( "\n" ); -} - -void config_parse_xresource_dump ( void ) -{ - const char * namePrefix = "rofi"; - unsigned int entries = sizeof ( xrmOptions ) / sizeof ( *xrmOptions ); - for ( unsigned int i = 0; i < entries; ++i ) { - // Skip duplicates. - if ( ( i + 1 ) < entries ) { - if ( xrmOptions[i].value.str == xrmOptions[i + 1].value.str ) { - continue; - } - } - xresource_dump_entry ( namePrefix, &( xrmOptions[i] ) ); - } - for ( unsigned int i = 0; i < num_extra_options; i++ ) { - xresource_dump_entry ( namePrefix, &( extra_options[i] ) ); - } -} static void config_parse_dump_config_option ( FILE *out, XrmOption *option ) { -- cgit v1.2.3