diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 248fa06e..dea1c5d1 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -13,7 +13,8 @@ SYNOPSIS [ -bg *color* ] [ -hlfg *color* ] [ -hlbg *color* ] [ -key *combo* ] [ -dkey *comdo* ] [ -rkey *comdo* ] [ -terminal *terminal* ] [ -loc *position* ] [ -hmode ] [ -fixed-num-lines ] [ -padding *padding* ] [ -opacity *opacity%* ] [ -display *display* ] [ -bc *color* ] [ -bw *width* ] [ -dmenu [ -p *prompt* ] ] -[ -ssh-set-title *true|false* ] [ -now ] [ -rnow ] [ -snow ] [ -version ] [ -help] [ -dump ] +[ -ssh-set-title *true|false* ] [ -now ] [ -rnow ] [ -snow ] [ -version ] [ -help] [ -dump ] +[ -dump-xresources ] DESCRIPTION ----------- @@ -204,6 +205,10 @@ OPTIONS Dump the current active configuration to the command-line. +`-dump-xresources` + + Dump the current active configuration in xresources format to the command-line. + `-ssh-set-title` *true|false* SSH dialogs tries to set 'ssh hostname' of the spawned terminal. diff --git a/doc/rofi.1 b/doc/rofi.1 index 11ea1e57..0449ab99 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -8,7 +8,8 @@ rofi \- A window switcher, run dialog and dmenu replacement [ \-bg \fIcolor\fP ] [ \-hlfg \fIcolor\fP ] [ \-hlbg \fIcolor\fP ] [ \-key \fIcombo\fP ] [ \-dkey \fIcomdo\fP ] [ \-rkey \fIcomdo\fP ] [ \-terminal \fIterminal\fP ] [ \-loc \fIposition\fP ] [ \-hmode ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\fP ] [ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc \fIcolor\fP ] [ \-bw \fIwidth\fP ] [ \-dmenu [ \-p \fIprompt\fP ] ] -[ \-ssh\-set\-title \fItrue|false\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump ] +[ \-ssh\-set\-title \fItrue|false\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump ] +[ \-dump\-xresources ] .SH DESCRIPTION .PP \fB\fCrofi\fR is an X11 popup window switcher. A list is displayed center\-screen showing open window titles, WM_CLASS, and desktop number. @@ -248,6 +249,10 @@ Run rofi in dmenu mode. Allowing it to be used for user interaction in scripts. .IP Dump the current active configuration to the command\-line. .PP +\fB\fC\-dump\-xresources\fR +.IP +Dump the current active configuration in xresources format to the command\-line. +.PP \fB\fC\-ssh\-set\-title\fR \fItrue|false\fP .IP SSH dialogs tries to set 'ssh hostname' of the spawned terminal. diff --git a/include/xrmoptions.h b/include/xrmoptions.h index 5a7a27f5..1adecc21 100644 --- a/include/xrmoptions.h +++ b/include/xrmoptions.h @@ -1,6 +1,9 @@ #ifndef __XRMOPTIONS_H__ #define __XRMOPTIONS_H__ + void parse_xresource_options ( Display *display ); void parse_xresource_free ( void ); + +void xresource_dump ( void ); #endif diff --git a/source/rofi.c b/source/rofi.c index a4217d6c..b57e2412 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -1952,6 +1952,12 @@ static void parse_cmd_options ( int argc, char ** argv ) config_print (); exit ( EXIT_SUCCESS ); } + + if ( find_arg ( argc, argv, "-dump-xresources" ) >= 0 ) + { + xresource_dump (); + exit ( EXIT_SUCCESS ); + } } static void cleanup () diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 5cd94246..6e51457f 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -182,3 +182,38 @@ void parse_xresource_free ( void ) } } } + +void xresource_dump ( void ) +{ + const char * namePrefix = "rofi"; + const char * classPrefix = "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].str == xrmOptions[i + 1].str ) + { + continue; + } + } + + printf ( "%s.%s: ", namePrefix, xrmOptions[i].name ); + switch ( xrmOptions[i].type ) + { + case xrm_Number: + printf ( "%i", *xrmOptions[i].num ); + break; + case xrm_String: + printf ( "%s", *xrmOptions[i].str ); + break; + case xrm_Boolean: + printf ( "%s", ( ( *xrmOptions[i].num ) == TRUE ) ? "true" : "false" ); + break; + default: + break; + } + printf ( "\n" ); + } +}