2014-02-03 15:46:44 -05:00
|
|
|
/**
|
2014-03-01 11:27:52 -05:00
|
|
|
* rofi
|
2014-02-03 15:46:44 -05:00
|
|
|
*
|
|
|
|
* MIT/X11 License
|
2015-04-14 16:12:21 -04:00
|
|
|
* Copyright 2013-2015 Qball Cow <qball@gmpclient.org>
|
2014-02-03 15:46:44 -05:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
2014-08-22 03:26:46 -04:00
|
|
|
#include <config.h>
|
2014-02-02 04:54:01 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include <X11/Xresource.h>
|
2014-03-12 03:41:38 -04:00
|
|
|
#include "rofi.h"
|
2014-02-02 04:54:01 -05:00
|
|
|
#include "xrmoptions.h"
|
2015-02-17 04:31:59 -05:00
|
|
|
#include "helper.h"
|
2014-02-02 04:54:01 -05:00
|
|
|
|
2014-03-22 16:04:19 -04:00
|
|
|
typedef struct
|
|
|
|
{
|
2015-02-15 15:15:16 -05:00
|
|
|
int type;
|
|
|
|
const char * name;
|
2014-03-22 16:04:19 -04:00
|
|
|
union
|
|
|
|
{
|
2014-02-02 04:54:01 -05:00
|
|
|
unsigned int * num;
|
2014-08-21 13:03:21 -04:00
|
|
|
int * snum;
|
2014-03-22 16:04:19 -04:00
|
|
|
char ** str;
|
2015-02-15 15:15:16 -05:00
|
|
|
void *pointer;
|
2015-02-17 04:31:59 -05:00
|
|
|
char * charc;
|
2015-03-07 11:22:25 -05:00
|
|
|
} value;
|
2014-05-19 15:58:13 -04:00
|
|
|
char *mem;
|
2014-02-02 04:54:01 -05:00
|
|
|
} XrmOption;
|
2014-05-19 11:54:53 -04:00
|
|
|
/**
|
2015-02-17 04:31:59 -05:00
|
|
|
* Map X resource and commandline options to internal options
|
|
|
|
* Currently supports string, boolean and number (signed and unsigned).
|
2014-05-19 11:54:53 -04:00
|
|
|
*/
|
2014-05-17 17:06:45 -04:00
|
|
|
static XrmOption xrmOptions[] = {
|
2015-04-06 09:23:58 -04:00
|
|
|
{ xrm_String, "switchers", { .str = &config.switchers }, NULL },
|
|
|
|
{ xrm_String, "modi", { .str = &config.switchers }, NULL },
|
|
|
|
{ xrm_Number, "opacity", { .num = &config.window_opacity }, NULL },
|
2014-05-22 03:18:16 -04:00
|
|
|
|
2015-04-06 09:23:58 -04:00
|
|
|
{ xrm_SNumber, "width", { .snum = &config.menu_width }, NULL },
|
2014-05-22 03:18:16 -04:00
|
|
|
|
2015-04-06 09:23:58 -04:00
|
|
|
{ xrm_Number, "lines", { .num = &config.menu_lines }, NULL },
|
|
|
|
{ xrm_Number, "columns", { .num = &config.menu_columns }, NULL },
|
2014-05-22 03:18:16 -04:00
|
|
|
|
2015-04-06 09:23:58 -04:00
|
|
|
{ xrm_String, "font", { .str = &config.menu_font }, NULL },
|
2014-05-22 03:18:16 -04:00
|
|
|
/* Foreground color */
|
2015-04-11 06:04:14 -04:00
|
|
|
{ xrm_String, "foreground", { .str = &config.menu_fg }, NULL },
|
2015-04-06 09:23:58 -04:00
|
|
|
{ xrm_String, "fg", { .str = &config.menu_fg }, NULL },
|
2015-04-11 06:04:14 -04:00
|
|
|
{ xrm_String, "background", { .str = &config.menu_bg }, NULL },
|
2015-04-06 11:13:26 -04:00
|
|
|
{ xrm_String, "bg", { .str = &config.menu_bg }, NULL },
|
|
|
|
|
2015-04-11 06:04:14 -04:00
|
|
|
{ xrm_Boolean, "color-enabled", { .num = &config.color_enabled }, NULL },
|
2015-04-06 11:13:26 -04:00
|
|
|
{ xrm_String, "color-normal", { .str = &config.color_normal }, NULL },
|
|
|
|
{ xrm_String, "color-urgent", { .str = &config.color_urgent }, NULL },
|
|
|
|
{ xrm_String, "color-active", { .str = &config.color_active }, NULL },
|
|
|
|
{ xrm_String, "color-window", { .str = &config.color_window }, NULL },
|
2015-04-06 09:23:58 -04:00
|
|
|
|
|
|
|
{ xrm_String, "fg-active", { .str = &config.menu_fg_active }, NULL },
|
|
|
|
{ xrm_String, "fg-urgent", { .str = &config.menu_fg_urgent }, NULL },
|
|
|
|
{ xrm_String, "hlfg-active", { .str = &config.menu_hlfg_active }, NULL },
|
|
|
|
{ xrm_String, "hlfg-urgent", { .str = &config.menu_hlfg_urgent }, NULL },
|
|
|
|
|
|
|
|
{ xrm_String, "bg-active", { .str = &config.menu_bg_active }, NULL },
|
|
|
|
{ xrm_String, "bg-urgent", { .str = &config.menu_bg_urgent }, NULL },
|
|
|
|
{ xrm_String, "hlbg-active", { .str = &config.menu_hlbg_active }, NULL },
|
|
|
|
{ xrm_String, "hlbg-urgent", { .str = &config.menu_hlbg_urgent }, NULL },
|
|
|
|
|
|
|
|
{ xrm_String, "background-alternate", { .str = &config.menu_bg_alt }, NULL },
|
|
|
|
{ xrm_String, "bgalt", { .str = &config.menu_bg_alt }, NULL },
|
|
|
|
|
|
|
|
{ xrm_String, "highlightfg", { .str = &config.menu_hlfg }, NULL },
|
|
|
|
{ xrm_String, "hlfg", { .str = &config.menu_hlfg }, NULL },
|
|
|
|
|
|
|
|
{ xrm_String, "highlightbg", { .str = &config.menu_hlbg }, NULL },
|
|
|
|
{ xrm_String, "hlbg", { .str = &config.menu_hlbg }, NULL },
|
|
|
|
|
|
|
|
{ xrm_String, "bordercolor", { .str = &config.menu_bc }, NULL },
|
|
|
|
{ xrm_String, "bc", { .str = &config.menu_bc }, NULL },
|
|
|
|
|
|
|
|
{ xrm_Number, "borderwidth", { .num = &config.menu_bw }, NULL },
|
|
|
|
{ xrm_Number, "bw", { .num = &config.menu_bw }, NULL },
|
|
|
|
|
|
|
|
{ xrm_Number, "location", { .num = &config.location }, NULL },
|
|
|
|
|
|
|
|
{ xrm_Number, "padding", { .num = &config.padding }, NULL },
|
|
|
|
{ xrm_SNumber, "yoffset", { .snum = &config.y_offset }, NULL },
|
|
|
|
{ xrm_SNumber, "xoffset", { .snum = &config.x_offset }, NULL },
|
|
|
|
{ xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines }, NULL },
|
|
|
|
|
|
|
|
{ xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL },
|
|
|
|
{ xrm_String, "ssh-client", { .str = &config.ssh_client }, NULL },
|
|
|
|
{ xrm_String, "ssh-command", { .str = &config.ssh_command }, NULL },
|
|
|
|
{ xrm_String, "run-command", { .str = &config.run_command }, NULL },
|
|
|
|
{ xrm_String, "run-list-command", { .str = &config.run_list_command }, NULL },
|
|
|
|
{ xrm_String, "run-shell-command", { .str = &config.run_shell_command }, NULL },
|
|
|
|
|
|
|
|
{ xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL },
|
|
|
|
{ xrm_Boolean, "levenshtein-sort", { .num = &config.levenshtein_sort }, NULL },
|
|
|
|
{ xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL },
|
|
|
|
{ xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL },
|
|
|
|
{ xrm_Number, "lazy-filter-limit", { .num = &config.lazy_filter_limit }, NULL },
|
|
|
|
{ xrm_SNumber, "eh", { .snum = &config.element_height }, NULL },
|
|
|
|
{ xrm_Boolean, "auto-select", { .num = &config.auto_select }, NULL },
|
|
|
|
{ xrm_Boolean, "parse-hosts", { .num = &config.parse_hosts }, NULL },
|
|
|
|
{ xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL }
|
2014-02-02 04:54:01 -05:00
|
|
|
};
|
|
|
|
|
2015-02-15 15:15:16 -05:00
|
|
|
// Dynamic options.
|
|
|
|
XrmOption *extra_options = NULL;
|
|
|
|
unsigned int num_extra_options = 0;
|
|
|
|
|
|
|
|
void config_parser_add_option ( XrmOptionType type, const char *key, void **value )
|
|
|
|
{
|
|
|
|
extra_options = g_realloc ( extra_options, ( num_extra_options + 1 ) * sizeof ( XrmOption ) );
|
|
|
|
|
2015-03-07 11:22:25 -05:00
|
|
|
extra_options[num_extra_options].type = type;
|
|
|
|
extra_options[num_extra_options].name = key;
|
2015-03-03 18:43:51 -05:00
|
|
|
extra_options[num_extra_options].value.pointer = value;
|
2015-02-15 15:15:16 -05:00
|
|
|
if ( type == xrm_String ) {
|
|
|
|
extra_options[num_extra_options].mem = ( (char *) ( *value ) );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
extra_options[num_extra_options].mem = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
num_extra_options++;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void config_parser_set ( XrmOption *option, XrmValue *xrmValue )
|
|
|
|
{
|
|
|
|
if ( option->type == xrm_String ) {
|
|
|
|
if ( ( option )->mem != NULL ) {
|
|
|
|
g_free ( option->mem );
|
|
|
|
option->mem = NULL;
|
|
|
|
}
|
2015-03-03 18:43:51 -05:00
|
|
|
*( option->value.str ) = g_strndup ( xrmValue->addr, xrmValue->size );
|
2015-02-15 15:15:16 -05:00
|
|
|
|
|
|
|
// Memory
|
2015-03-03 18:43:51 -05:00
|
|
|
( option )->mem = *( option->value.str );
|
2015-02-15 15:15:16 -05:00
|
|
|
}
|
|
|
|
else if ( option->type == xrm_Number ) {
|
2015-03-03 18:43:51 -05:00
|
|
|
*( option->value.num ) = (unsigned int) strtoul ( xrmValue->addr, NULL, 10 );
|
2015-02-15 15:15:16 -05:00
|
|
|
}
|
|
|
|
else if ( option->type == xrm_SNumber ) {
|
2015-03-03 18:43:51 -05:00
|
|
|
*( option->value.snum ) = (int) strtol ( xrmValue->addr, NULL, 10 );
|
2015-02-15 15:15:16 -05:00
|
|
|
}
|
|
|
|
else if ( option->type == xrm_Boolean ) {
|
|
|
|
if ( xrmValue->size > 0 && g_ascii_strncasecmp ( xrmValue->addr, "true", xrmValue->size ) == 0 ) {
|
2015-03-03 18:43:51 -05:00
|
|
|
*( option->value.num ) = TRUE;
|
2015-02-15 15:15:16 -05:00
|
|
|
}
|
|
|
|
else{
|
2015-03-03 18:43:51 -05:00
|
|
|
*( option->value.num ) = FALSE;
|
2015-02-15 15:15:16 -05:00
|
|
|
}
|
|
|
|
}
|
2015-02-17 04:31:59 -05:00
|
|
|
else if ( option->type == xrm_Char ) {
|
2015-03-03 18:43:51 -05:00
|
|
|
*( option->value.charc ) = helper_parse_char ( xrmValue->addr );
|
2015-02-17 04:31:59 -05:00
|
|
|
}
|
2015-02-15 15:15:16 -05:00
|
|
|
}
|
2014-02-02 04:54:01 -05:00
|
|
|
|
2015-02-03 02:21:59 -05:00
|
|
|
void config_parse_xresource_options ( Display *display )
|
2014-02-02 04:54:01 -05:00
|
|
|
{
|
2014-05-17 17:06:45 -04:00
|
|
|
char *xRMS;
|
2014-05-19 11:54:53 -04:00
|
|
|
// Map Xresource entries to rofi config options.
|
2014-03-22 16:04:19 -04:00
|
|
|
XrmInitialize ();
|
2014-05-17 17:06:45 -04:00
|
|
|
xRMS = XResourceManagerString ( display );
|
2014-02-02 04:54:01 -05:00
|
|
|
|
2014-06-04 15:29:23 -04:00
|
|
|
if ( xRMS == NULL ) {
|
2014-05-19 11:54:53 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
XrmDatabase xDB = XrmGetStringDatabase ( xRMS );
|
2014-02-02 04:54:01 -05:00
|
|
|
|
2014-05-19 11:54:53 -04:00
|
|
|
char * xrmType;
|
|
|
|
XrmValue xrmValue;
|
|
|
|
const char * namePrefix = "rofi";
|
2014-05-19 15:58:13 -04:00
|
|
|
const char * classPrefix = "rofi";
|
2014-02-02 04:54:01 -05:00
|
|
|
|
2015-02-15 15:15:16 -05:00
|
|
|
for ( unsigned int i = 0; i < sizeof ( xrmOptions ) / sizeof ( XrmOption ); ++i ) {
|
2014-05-19 15:58:13 -04:00
|
|
|
char *name, *class;
|
2014-08-09 05:40:42 -04:00
|
|
|
|
|
|
|
name = g_strdup_printf ( "%s.%s", namePrefix, xrmOptions[i].name );
|
|
|
|
class = g_strdup_printf ( "%s.%s", classPrefix, xrmOptions[i].name );
|
|
|
|
|
|
|
|
if ( XrmGetResource ( xDB, name, class, &xrmType, &xrmValue ) ) {
|
2015-02-15 15:15:16 -05:00
|
|
|
config_parser_set ( &( xrmOptions[i] ), &xrmValue );
|
|
|
|
}
|
|
|
|
|
|
|
|
g_free ( class );
|
|
|
|
g_free ( name );
|
|
|
|
}
|
|
|
|
XrmDestroyDatabase ( xDB );
|
|
|
|
}
|
|
|
|
|
2015-02-17 04:31:59 -05:00
|
|
|
/**
|
|
|
|
* Parse an option from the commandline vector.
|
|
|
|
*/
|
2015-03-11 13:32:37 -04:00
|
|
|
static void config_parse_cmd_option ( XrmOption *option )
|
2015-02-17 04:31:59 -05:00
|
|
|
{
|
|
|
|
// Prepend a - to the option name.
|
|
|
|
char *key = g_strdup_printf ( "-%s", option->name );
|
|
|
|
switch ( option->type )
|
|
|
|
{
|
|
|
|
case xrm_Number:
|
2015-03-11 13:32:37 -04:00
|
|
|
find_arg_uint ( key, option->value.num );
|
2015-02-17 04:31:59 -05:00
|
|
|
break;
|
|
|
|
case xrm_SNumber:
|
2015-03-11 13:32:37 -04:00
|
|
|
find_arg_int ( key, option->value.snum );
|
2015-02-17 04:31:59 -05:00
|
|
|
break;
|
|
|
|
case xrm_String:
|
2015-03-11 13:32:37 -04:00
|
|
|
if ( find_arg_str ( key, option->value.str ) == TRUE ) {
|
2015-02-17 04:31:59 -05:00
|
|
|
if ( option->mem != NULL ) {
|
|
|
|
g_free ( option->mem );
|
|
|
|
option->mem = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case xrm_Boolean:
|
2015-03-11 13:32:37 -04:00
|
|
|
if ( find_arg ( key ) >= 0 ) {
|
2015-03-03 18:43:51 -05:00
|
|
|
*( option->value.num ) = TRUE;
|
2015-02-17 04:31:59 -05:00
|
|
|
}
|
2015-04-19 07:19:20 -04:00
|
|
|
else {
|
|
|
|
g_free ( key );
|
|
|
|
key = g_strdup_printf ( "-no-%s", option->name );
|
|
|
|
if ( find_arg ( key ) >= 0 ) {
|
|
|
|
*( option->value.num ) = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2015-02-17 04:31:59 -05:00
|
|
|
break;
|
|
|
|
case xrm_Char:
|
2015-03-11 13:32:37 -04:00
|
|
|
find_arg_char ( key, option->value.charc );
|
2015-02-17 04:31:59 -05:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
g_free ( key );
|
|
|
|
}
|
|
|
|
|
2015-03-11 13:32:37 -04:00
|
|
|
void config_parse_cmd_options ( void )
|
2015-02-17 04:31:59 -05:00
|
|
|
{
|
|
|
|
for ( unsigned int i = 0; i < sizeof ( xrmOptions ) / sizeof ( XrmOption ); ++i ) {
|
|
|
|
XrmOption *op = &( xrmOptions[i] );
|
2015-03-11 13:32:37 -04:00
|
|
|
config_parse_cmd_option ( op );
|
2015-02-17 04:31:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-11 13:32:37 -04:00
|
|
|
void config_parse_cmd_options_dynamic ( void )
|
2015-02-17 04:31:59 -05:00
|
|
|
{
|
|
|
|
for ( unsigned int i = 0; i < num_extra_options; ++i ) {
|
|
|
|
XrmOption *op = &( extra_options[i] );
|
2015-03-11 13:32:37 -04:00
|
|
|
config_parse_cmd_option ( op );
|
2015-02-17 04:31:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-15 15:15:16 -05:00
|
|
|
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 );
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
name = g_strdup_printf ( "%s.%s", namePrefix, extra_options[i].name );
|
|
|
|
class = g_strdup_printf ( "%s.%s", classPrefix, extra_options[i].name );
|
|
|
|
if ( XrmGetResource ( xDB, name, class, &xrmType, &xrmValue ) ) {
|
|
|
|
config_parser_set ( &( extra_options[i] ), &xrmValue );
|
2014-02-02 04:54:01 -05:00
|
|
|
}
|
2014-08-09 05:40:42 -04:00
|
|
|
|
|
|
|
g_free ( class );
|
|
|
|
g_free ( name );
|
2014-02-02 04:54:01 -05:00
|
|
|
}
|
2014-05-19 15:58:13 -04:00
|
|
|
XrmDestroyDatabase ( xDB );
|
|
|
|
}
|
|
|
|
|
2015-02-03 02:21:59 -05:00
|
|
|
void config_xresource_free ( void )
|
2014-05-19 15:58:13 -04:00
|
|
|
{
|
2015-02-15 15:15:16 -05:00
|
|
|
for ( unsigned int i = 0; i < ( sizeof ( xrmOptions ) / sizeof ( *xrmOptions ) ); ++i ) {
|
2014-06-04 15:29:23 -04:00
|
|
|
if ( xrmOptions[i].mem != NULL ) {
|
2014-08-09 05:40:42 -04:00
|
|
|
g_free ( xrmOptions[i].mem );
|
2014-05-19 15:58:13 -04:00
|
|
|
xrmOptions[i].mem = NULL;
|
|
|
|
}
|
|
|
|
}
|
2015-02-15 15:15:16 -05:00
|
|
|
for ( unsigned int i = 0; i < num_extra_options; ++i ) {
|
|
|
|
if ( extra_options[i].mem != NULL ) {
|
|
|
|
g_free ( extra_options[i].mem );
|
|
|
|
extra_options[i].mem = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( extra_options != NULL ) {
|
|
|
|
g_free ( extra_options );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-18 02:53:38 -05:00
|
|
|
static void xresource_dump_entry ( const char *namePrefix, XrmOption *option )
|
2015-02-15 15:15:16 -05:00
|
|
|
{
|
|
|
|
printf ( "%s.%s: %*s", namePrefix, option->name,
|
2015-05-02 06:08:50 -04:00
|
|
|
(int) ( 30 - strlen ( option->name ) ), "" );
|
2015-02-15 15:15:16 -05:00
|
|
|
switch ( option->type )
|
|
|
|
{
|
|
|
|
case xrm_Number:
|
2015-03-03 18:43:51 -05:00
|
|
|
printf ( "%u", *( option->value.num ) );
|
2015-02-15 15:15:16 -05:00
|
|
|
break;
|
|
|
|
case xrm_SNumber:
|
2015-03-03 18:43:51 -05:00
|
|
|
printf ( "%i", *( option->value.snum ) );
|
2015-02-15 15:15:16 -05:00
|
|
|
break;
|
|
|
|
case xrm_String:
|
2015-03-03 18:43:51 -05:00
|
|
|
if ( ( *( option->value.str ) ) != NULL ) {
|
|
|
|
printf ( "%s", *( option->value.str ) );
|
2015-02-15 15:15:16 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case xrm_Boolean:
|
2015-03-03 18:43:51 -05:00
|
|
|
printf ( "%s", ( *( option->value.num ) == TRUE ) ? "true" : "false" );
|
2015-02-15 15:15:16 -05:00
|
|
|
break;
|
2015-02-17 04:31:59 -05:00
|
|
|
case xrm_Char:
|
2015-03-03 18:43:51 -05:00
|
|
|
if ( *( option->value.charc ) > 32 && *( option->value.charc ) < 127 ) {
|
|
|
|
printf ( "%c", *( option->value.charc ) );
|
2015-02-17 04:31:59 -05:00
|
|
|
}
|
|
|
|
else {
|
2015-03-03 18:43:51 -05:00
|
|
|
printf ( "\\x%02X", *( option->value.charc ) );
|
2015-02-17 04:31:59 -05:00
|
|
|
}
|
|
|
|
break;
|
2015-02-15 15:15:16 -05:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
printf ( "\n" );
|
2014-02-02 04:54:01 -05:00
|
|
|
}
|
2014-05-22 15:56:57 -04:00
|
|
|
|
|
|
|
void xresource_dump ( void )
|
|
|
|
{
|
2014-05-24 10:23:01 -04:00
|
|
|
const char * namePrefix = "rofi";
|
|
|
|
unsigned int entries = sizeof ( xrmOptions ) / sizeof ( *xrmOptions );
|
2014-06-04 15:29:23 -04:00
|
|
|
for ( unsigned int i = 0; i < entries; ++i ) {
|
2014-05-22 15:56:57 -04:00
|
|
|
// Skip duplicates.
|
2014-06-04 15:29:23 -04:00
|
|
|
if ( ( i + 1 ) < entries ) {
|
2015-03-03 18:43:51 -05:00
|
|
|
if ( xrmOptions[i].value.str == xrmOptions[i + 1].value.str ) {
|
2014-05-22 15:56:57 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2015-02-15 15:15:16 -05:00
|
|
|
xresource_dump_entry ( namePrefix, &( xrmOptions[i] ) );
|
|
|
|
}
|
|
|
|
for ( unsigned int i = 0; i < num_extra_options; i++ ) {
|
|
|
|
xresource_dump_entry ( namePrefix, &( extra_options[i] ) );
|
2014-05-22 15:56:57 -04:00
|
|
|
}
|
|
|
|
}
|