summaryrefslogtreecommitdiffstats
path: root/source/xrmoptions.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-01-03 13:30:43 +0100
committerDave Davenport <qball@gmpclient.org>2016-01-03 13:30:43 +0100
commitbd3d472bec60babf29cc84d98a35dd7b3edd200a (patch)
tree562356b9702f48265e885d617c2940b766b3086e /source/xrmoptions.c
parent4fbbce891bba56171b5b6fc5d6442427bad56a75 (diff)
Add optional config file that overrides local Xresources
Rofi will look at XDG_CONFIG_USER_DIR/rofi/config and load this after the Xresources db on DISPLAY. This can be overridden using the -config commandline option. The file should be in the same format as the Xresources file.
Diffstat (limited to 'source/xrmoptions.c')
-rw-r--r--source/xrmoptions.c95
1 files changed, 65 insertions, 30 deletions
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index d1b4d029..d81053a2 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -196,22 +196,12 @@ static void config_parser_set ( XrmOption *option, XrmValue *xrmValue )
}
}
-void config_parse_xresource_options ( Display *display )
+static void __config_parse_xresource_options ( XrmDatabase xDB )
{
- char *xRMS;
- // Map Xresource entries to rofi config options.
- XrmInitialize ();
- xRMS = XResourceManagerString ( display );
-
- if ( xRMS == NULL ) {
- return;
- }
- XrmDatabase xDB = XrmGetStringDatabase ( xRMS );
-
- char * xrmType;
- XrmValue xrmValue;
- const char * namePrefix = "rofi";
- const char * classPrefix = "rofi";
+ char * xrmType;
+ XrmValue xrmValue;
+ const char * namePrefix = "rofi";
+ const char * classPrefix = "rofi";
for ( unsigned int i = 0; i < sizeof ( xrmOptions ) / sizeof ( XrmOption ); ++i ) {
char *name, *class;
@@ -226,6 +216,33 @@ void config_parse_xresource_options ( Display *display )
g_free ( class );
g_free ( name );
}
+}
+void config_parse_xresource_options ( Display *display )
+{
+ char *xRMS;
+ // Map Xresource entries to rofi config options.
+ XrmInitialize ();
+ xRMS = XResourceManagerString ( display );
+
+ if ( xRMS == NULL ) {
+ return;
+ }
+ XrmDatabase xDB = XrmGetStringDatabase ( xRMS );
+ __config_parse_xresource_options ( xDB );
+ XrmDestroyDatabase ( xDB );
+}
+void config_parse_xresource_options_file ( const char *filename )
+{
+ if ( !filename ) {
+ return;
+ }
+ // Map Xresource entries to rofi config options.
+ XrmInitialize ();
+ XrmDatabase xDB = XrmGetFileDatabase ( filename );
+ if ( xDB == NULL ) {
+ return;
+ }
+ __config_parse_xresource_options ( xDB );
XrmDestroyDatabase ( xDB );
}
@@ -289,22 +306,12 @@ void config_parse_cmd_options_dynamic ( void )
}
}
-void config_parse_xresource_options_dynamic ( Display *display )
+static void __config_parse_xresource_options_dynamic ( XrmDatabase xDB )
{
- char *xRMS;
- // Map Xresource entries to rofi config options.
- XrmInitialize ();
- xRMS = XResourceManagerString ( display );
-
- if ( xRMS == NULL ) {
- return;
- }
- XrmDatabase xDB = XrmGetStringDatabase ( xRMS );
-
- char * xrmType;
- XrmValue xrmValue;
- const char * namePrefix = "rofi";
- const char * classPrefix = "rofi";
+ char * xrmType;
+ XrmValue xrmValue;
+ const char * namePrefix = "rofi";
+ const char * classPrefix = "rofi";
for ( unsigned int i = 0; i < num_extra_options; ++i ) {
char *name, *class;
@@ -318,6 +325,34 @@ void config_parse_xresource_options_dynamic ( Display *display )
g_free ( class );
g_free ( name );
}
+}
+
+void config_parse_xresource_options_dynamic ( Display *display )
+{
+ char *xRMS;
+ // Map Xresource entries to rofi config options.
+ XrmInitialize ();
+ xRMS = XResourceManagerString ( display );
+
+ if ( xRMS == NULL ) {
+ return;
+ }
+ XrmDatabase xDB = XrmGetStringDatabase ( xRMS );
+ __config_parse_xresource_options_dynamic ( xDB );
+ XrmDestroyDatabase ( xDB );
+}
+void config_parse_xresource_options_dynamic_file ( const char *filename )
+{
+ if ( !filename ) {
+ return;
+ }
+ // Map Xresource entries to rofi config options.
+ XrmInitialize ();
+ XrmDatabase xDB = XrmGetFileDatabase ( filename );
+ if ( xDB == NULL ) {
+ return;
+ }
+ __config_parse_xresource_options_dynamic ( xDB );
XrmDestroyDatabase ( xDB );
}