mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
[Configuration] Remove old configuration format.
This commit is contained in:
parent
3cd7170a8d
commit
5a7df38ccd
6 changed files with 6 additions and 199 deletions
|
@ -38,8 +38,6 @@ You can also use [Meson](https://mesonbuild.com/) as an alternative.
|
||||||
* libxcb (sometimes split, you need libxcb, libxcb-xkb and libxcb-randr libxcb-xinerama)
|
* libxcb (sometimes split, you need libxcb, libxcb-xkb and libxcb-randr libxcb-xinerama)
|
||||||
* xcb-util
|
* xcb-util
|
||||||
* xcb-util-wm (sometimes split as libxcb-ewmh and libxcb-icccm)
|
* xcb-util-wm (sometimes split as libxcb-ewmh and libxcb-icccm)
|
||||||
* xcb-util-xrm [new module might not be available in your distribution. The source can be found
|
|
||||||
here](https://github.com/Airblader/xcb-util-xrm/)
|
|
||||||
* xcb-util-cursor
|
* xcb-util-cursor
|
||||||
|
|
||||||
On debian based systems, the developer packages are in the form of: `<package>-dev` on rpm based
|
On debian based systems, the developer packages are in the form of: `<package>-dev` on rpm based
|
||||||
|
|
|
@ -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])
|
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_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])
|
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-cursor xcb-randr xcb-xinerama])
|
GW_CHECK_XCB([xcb-aux xcb-xkb xkbcommon xkbcommon-x11 xcb-ewmh xcb-icccm xcb-cursor xcb-randr xcb-xinerama])
|
||||||
PKG_CHECK_MODULES([pango], [pango pangocairo])
|
PKG_CHECK_MODULES([pango], [pango pangocairo])
|
||||||
PKG_CHECK_MODULES([cairo], [cairo cairo-xcb])
|
PKG_CHECK_MODULES([cairo], [cairo cairo-xcb])
|
||||||
PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0 ])
|
PKG_CHECK_MODULES([libsn], [libstartup-notification-1.0 ])
|
||||||
|
|
|
@ -80,14 +80,6 @@ typedef enum
|
||||||
xrm_Char = 4
|
xrm_Char = 4
|
||||||
} XrmOptionType;
|
} XrmOptionType;
|
||||||
|
|
||||||
/**
|
|
||||||
* @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.
|
* Parse commandline options.
|
||||||
* @ingroup CONFCommandline
|
* @ingroup CONFCommandline
|
||||||
|
|
|
@ -64,7 +64,6 @@ deps += [
|
||||||
dependency('xkbcommon-x11'),
|
dependency('xkbcommon-x11'),
|
||||||
dependency('xcb-ewmh'),
|
dependency('xcb-ewmh'),
|
||||||
dependency('xcb-icccm'),
|
dependency('xcb-icccm'),
|
||||||
dependency('xcb-xrm'),
|
|
||||||
dependency('xcb-randr'),
|
dependency('xcb-randr'),
|
||||||
dependency('xcb-cursor'),
|
dependency('xcb-cursor'),
|
||||||
dependency('xcb-xinerama'),
|
dependency('xcb-xinerama'),
|
||||||
|
|
103
source/rofi.c
103
source/rofi.c
|
@ -95,7 +95,6 @@ void rofi_add_error_message ( GString *str )
|
||||||
/** Path to the configuration file */
|
/** Path to the configuration file */
|
||||||
G_MODULE_EXPORT char *config_path = NULL;
|
G_MODULE_EXPORT char *config_path = NULL;
|
||||||
/** Path to the configuration file in the new format */
|
/** Path to the configuration file in the new format */
|
||||||
G_MODULE_EXPORT char *config_path_new = NULL;
|
|
||||||
/** Array holding all activated modi. */
|
/** Array holding all activated modi. */
|
||||||
Mode **modi = NULL;
|
Mode **modi = NULL;
|
||||||
|
|
||||||
|
@ -119,8 +118,6 @@ static int dmenu_mode = FALSE;
|
||||||
/** Rofi's return code */
|
/** Rofi's return code */
|
||||||
int return_code = EXIT_SUCCESS;
|
int return_code = EXIT_SUCCESS;
|
||||||
|
|
||||||
/** Flag indicating we are using old config format. */
|
|
||||||
static gboolean old_config_format = FALSE;
|
|
||||||
|
|
||||||
void process_result ( RofiViewState *state );
|
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 ( "-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 ( "-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 ( "-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 );
|
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 )
|
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 ( " 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 : "" );
|
printf ( " %s#rofi @ libera.chat%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
|
||||||
if ( find_arg ( "-no-config" ) < 0 ) {
|
if ( find_arg ( "-no-config" ) < 0 ) {
|
||||||
if ( config_path_new ) {
|
if ( config_path ) {
|
||||||
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 : "" );
|
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 ( modi );
|
||||||
|
|
||||||
g_free ( config_path );
|
g_free ( config_path );
|
||||||
g_free ( config_path_new );
|
|
||||||
|
|
||||||
if ( list_of_error_msgs ) {
|
if ( list_of_error_msgs ) {
|
||||||
for ( GList *iter = g_list_first ( 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 ) {
|
if ( find_arg ( "-config" ) < 0 ) {
|
||||||
const char *cpath = g_get_user_config_dir ();
|
const char *cpath = g_get_user_config_dir ();
|
||||||
if ( cpath ) {
|
if ( cpath ) {
|
||||||
config_path = g_build_filename ( cpath, "rofi", "config", NULL );
|
config_path = g_build_filename ( cpath, "rofi", "config.rasi", NULL );
|
||||||
config_path_new = g_strconcat ( config_path, ".rasi", NULL );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char *c = NULL;
|
char *c = NULL;
|
||||||
find_arg_str ( "-config", &c );
|
find_arg_str ( "-config", &c );
|
||||||
if ( g_str_has_suffix ( c, ".rasi" ) ) {
|
config_path = rofi_expand_path ( c );
|
||||||
config_path_new = rofi_expand_path ( c );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
config_path = rofi_expand_path ( c );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TICK ();
|
TICK ();
|
||||||
|
@ -908,17 +894,6 @@ int main ( int argc, char *argv[] )
|
||||||
rofi_theme_parse_file ( etc );
|
rofi_theme_parse_file ( etc );
|
||||||
found_system = TRUE;
|
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 );
|
g_free ( etc );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -930,33 +905,15 @@ int main ( int argc, char *argv[] )
|
||||||
g_debug ( "Look for default config file: %s", etc );
|
g_debug ( "Look for default config file: %s", etc );
|
||||||
rofi_theme_parse_file ( 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 );
|
g_free ( etc );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( config_path_new && g_file_test ( config_path_new, G_FILE_TEST_IS_REGULAR ) ) {
|
if ( config_path && g_file_test ( config_path, G_FILE_TEST_IS_REGULAR ) ) {
|
||||||
if ( rofi_theme_parse_file ( config_path_new ) ) {
|
if ( rofi_theme_parse_file ( config_path ) ) {
|
||||||
rofi_theme_free ( rofi_theme );
|
rofi_theme_free ( rofi_theme );
|
||||||
rofi_theme = NULL;
|
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 ) );
|
find_arg_str ( "-theme", &( config.theme ) );
|
||||||
if ( config.theme ) {
|
if ( config.theme ) {
|
||||||
|
@ -972,10 +929,6 @@ int main ( int argc, char *argv[] )
|
||||||
config_parse_cmd_options ( );
|
config_parse_cmd_options ( );
|
||||||
TICK_N ( "Load cmd config " );
|
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 );
|
parse_keys_abe ( bindings );
|
||||||
|
|
||||||
// Get the path to the cache dir.
|
// Get the path to the cache dir.
|
||||||
|
@ -1052,52 +1005,6 @@ int main ( int argc, char *argv[] )
|
||||||
cleanup ();
|
cleanup ();
|
||||||
return EXIT_SUCCESS;
|
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 ) {
|
if ( find_arg ( "-dump-config" ) >= 0 ) {
|
||||||
config_parse_dump_config_rasi_format ( stdout, FALSE );
|
config_parse_dump_config_rasi_format ( stdout, FALSE );
|
||||||
cleanup ();
|
cleanup ();
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#include <xcb/xkb.h>
|
#include <xcb/xkb.h>
|
||||||
#include <xcb/xcb_xrm.h>
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include "xcb.h"
|
#include "xcb.h"
|
||||||
#include "xcb-internal.h"
|
#include "xcb-internal.h"
|
||||||
|
@ -260,94 +259,6 @@ void config_parser_add_option ( XrmOptionType type, const char *key, void **valu
|
||||||
num_extra_options++;
|
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.
|
* Parse an option from the commandline vector.
|
||||||
|
|
Loading…
Reference in a new issue