1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Add option to dump xresources entries.

This commit is contained in:
QC 2014-05-22 21:56:57 +02:00
parent 8ea7a7b5ab
commit 87958d4cad
5 changed files with 56 additions and 2 deletions

View file

@ -14,6 +14,7 @@ SYNOPSIS
[ -terminal *terminal* ] [ -loc *position* ] [ -hmode ] [ -fixed-num-lines ] [ -padding *padding* ] [ -terminal *terminal* ] [ -loc *position* ] [ -hmode ] [ -fixed-num-lines ] [ -padding *padding* ]
[ -opacity *opacity%* ] [ -display *display* ] [ -bc *color* ] [ -bw *width* ] [ -dmenu [ -p *prompt* ] ] [ -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 DESCRIPTION
----------- -----------
@ -204,6 +205,10 @@ OPTIONS
Dump the current active configuration to the command-line. 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-set-title` *true|false*
SSH dialogs tries to set 'ssh hostname' of the spawned terminal. SSH dialogs tries to set 'ssh hostname' of the spawned terminal.

View file

@ -9,6 +9,7 @@ rofi \- A window switcher, run dialog and dmenu replacement
[ \-terminal \fIterminal\fP ] [ \-loc \fIposition\fP ] [ \-hmode ] [ \-fixed\-num\-lines ] [ \-padding \fIpadding\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 ] ] [ \-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 .SH DESCRIPTION
.PP .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. \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 .IP
Dump the current active configuration to the command\-line. Dump the current active configuration to the command\-line.
.PP .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 \fB\fC\-ssh\-set\-title\fR \fItrue|false\fP
.IP .IP
SSH dialogs tries to set 'ssh hostname' of the spawned terminal. SSH dialogs tries to set 'ssh hostname' of the spawned terminal.

View file

@ -1,6 +1,9 @@
#ifndef __XRMOPTIONS_H__ #ifndef __XRMOPTIONS_H__
#define __XRMOPTIONS_H__ #define __XRMOPTIONS_H__
void parse_xresource_options ( Display *display ); void parse_xresource_options ( Display *display );
void parse_xresource_free ( void ); void parse_xresource_free ( void );
void xresource_dump ( void );
#endif #endif

View file

@ -1952,6 +1952,12 @@ static void parse_cmd_options ( int argc, char ** argv )
config_print (); config_print ();
exit ( EXIT_SUCCESS ); exit ( EXIT_SUCCESS );
} }
if ( find_arg ( argc, argv, "-dump-xresources" ) >= 0 )
{
xresource_dump ();
exit ( EXIT_SUCCESS );
}
} }
static void cleanup () static void cleanup ()

View file

@ -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" );
}
}