1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00
Conflicts:
	doc/rofi-manpage.markdown
	doc/rofi.1
This commit is contained in:
Edwin Pujols 2015-01-12 15:48:04 -04:00
commit 32b8281cfb
9 changed files with 119 additions and 67 deletions

View file

@ -50,6 +50,8 @@ Settings config = {
.menu_fg = "#222222", .menu_fg = "#222222",
/** Background color */ /** Background color */
.menu_bg = "#f2f1f0", .menu_bg = "#f2f1f0",
/** Background color alternate row */
.menu_bg_alt = NULL,
/** Foreground color (selected) */ /** Foreground color (selected) */
.menu_hlfg = "#ffffff", .menu_hlfg = "#ffffff",
/** Background color (selected) */ /** Background color (selected) */

View file

@ -7,13 +7,14 @@ rofi - A window switcher, run dialog and dmenu replacement
## SYNOPSIS ## SYNOPSIS
**rofi** [ -width *pct_scr* ] [ -lines *lines* ] [ -columns *columns* ] [ -font *pangofont* ] [ -fg **rofi** [ -width *pct_scr* ] [ -lines *lines* ] [ -columns *columns* ] [ -font *pangofont* ] [ -fg
*color* ] [ -bg *color* ] [ -hlfg *color* ] [ -hlbg *color* ] [ -key *combo* ] [ -dkey *comdo* ] [ *color* ] [ -bg *color* ] [ -bgalt *color* ] [ -hlfg *color* ] [ -hlbg *color* ] [ -key *combo* ] [
-rkey *comdo* ] [ -terminal *terminal* ] [ -location *position* ] [ -hmode ] [ -fixed-num-lines ] [ -dkey *comdo* ] [ -rkey *comdo* ] [ -terminal *terminal* ] [ -location *position* ] [ -hmode ] [
-padding *padding* ] [ -opacity *opacity%* ] [ -display *display* ] [ -bc *color* ] [ -bw *width* ] -fixed-num-lines ] [ -padding *padding* ] [ -opacity *opacity%* ] [ -display *display* ] [ -bc
[ -dmenu [ -p *prompt* ] ] [ -ssh-client *client* ] [ -ssh-command *command* ] [ -now ] [ -rnow ] [ *color* ] [ -bw *width* ] [ -dmenu [ -p *prompt* ] ] [ -ssh-client *client* ] [ -ssh-command
-snow ] [ -version ] [ -help] [ -dump-xresources ] [ -disable-history ] [ -levenshtein-sort ] [ *command* ] [ -now ] [ -rnow ] [ -snow ] [ -version ] [ -help] [ -dump-xresources ] [
-case-sensitive ] [ -show *mode* ] [ -switcher *mode1,mode2* ] [ -e *message*] [ -sep *separator* ] -disable-history ] [ -levenshtein-sort ] [ -case-sensitive ] [ -show *mode* ] [ -switcher *mode1,
[ -eh *element height* ] [ -l *selected line* ] [ -run-list-command *cmd* ] mode2* ] [ -e *message*] [ -sep *separator* ] [ -eh *element height* ] [ -l *selected line* ] [
-run-list-command *cmd* ]
## DESCRIPTION ## DESCRIPTION
@ -129,8 +130,14 @@ The default key combinations are:
Set the background text color (X11 named color or hex #rrggbb) for the menu (default: #222222). Set the background text color (X11 named color or hex #rrggbb) for the menu (default: #222222).
rofi -fg "#222222" rofi -bg "#222222"
`-bg`
Set the background text color for alternating rows (X11 named color or hex #rrggbb) for the menu
(default: #222222).
rofi -bgalt "#222222"
`-bc` `-bc`

View file

@ -5,13 +5,14 @@ rofi \- A window switcher, run dialog and dmenu replacement
.SH SYNOPSIS .SH SYNOPSIS
.PP .PP
\fBrofi\fP [ \-width \fIpct_scr\fP ] [ \-lines \fIlines\fP ] [ \-columns \fIcolumns\fP ] [ \-font \fIpangofont\fP ] [ \-fg \fBrofi\fP [ \-width \fIpct_scr\fP ] [ \-lines \fIlines\fP ] [ \-columns \fIcolumns\fP ] [ \-font \fIpangofont\fP ] [ \-fg
\fIcolor\fP ] [ \-bg \fIcolor\fP ] [ \-hlfg \fIcolor\fP ] [ \-hlbg \fIcolor\fP ] [ \-key \fIcombo\fP ] [ \-dkey \fIcomdo\fP ] [ \fIcolor\fP ] [ \-bg \fIcolor\fP ] [ \-bgalt \fIcolor\fP ] [ \-hlfg \fIcolor\fP ] [ \-hlbg \fIcolor\fP ] [ \-key \fIcombo\fP ] [
\-rkey \fIcomdo\fP ] [ \-terminal \fIterminal\fP ] [ \-location \fIposition\fP ] [ \-hmode ] [ \-fixed\-num\-lines ] [ \-dkey \fIcomdo\fP ] [ \-rkey \fIcomdo\fP ] [ \-terminal \fIterminal\fP ] [ \-location \fIposition\fP ] [ \-hmode ] [
\-padding \fIpadding\fP ] [ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc \fIcolor\fP ] [ \-bw \fIwidth\fP ] \-fixed\-num\-lines ] [ \-padding \fIpadding\fP ] [ \-opacity \fIopacity%\fP ] [ \-display \fIdisplay\fP ] [ \-bc
[ \-dmenu [ \-p \fIprompt\fP ] ] [ \-ssh\-client \fIclient\fP ] [ \-ssh\-command \fIcommand\fP ] [ \-now ] [ \-rnow ] [ \fIcolor\fP ] [ \-bw \fIwidth\fP ] [ \-dmenu [ \-p \fIprompt\fP ] ] [ \-ssh\-client \fIclient\fP ] [ \-ssh\-command
\-snow ] [ \-version ] [ \-help] [ \-dump\-xresources ] [ \-disable\-history ] [ \-levenshtein\-sort ] [ \fIcommand\fP ] [ \-now ] [ \-rnow ] [ \-snow ] [ \-version ] [ \-help] [ \-dump\-xresources ] [
\-case\-sensitive ] [ \-show \fImode\fP ] [ \-switcher \fImode1,mode2\fP ] [ \-e \fImessage\fP] [ \-sep \fIseparator\fP ] \-disable\-history ] [ \-levenshtein\-sort ] [ \-case\-sensitive ] [ \-show \fImode\fP ] [ \-switcher \fImode1,
[ \-eh \fIelement height\fP ] [ \-l \fIselected line\fP ] [ \-run\-list\-command \fIcmd\fP ] mode2\fP ] [ \-e \fImessage\fP] [ \-sep \fIseparator\fP ] [ \-eh \fIelement height\fP ] [ \-l \fIselected line\fP ] [
\-run\-list\-command \fIcmd\fP ]
.SH DESCRIPTION .SH DESCRIPTION
.PP .PP
\fBrofi\fP is an X11 popup window switcher. A list is displayed center\-screen showing open window titles, WM_CLASS, and desktop number. \fBrofi\fP is an X11 popup window switcher. A list is displayed center\-screen showing open window titles, WM_CLASS, and desktop number.
@ -152,7 +153,18 @@ Set the background text color (X11 named color or hex #rrggbb) for the menu (def
.PP .PP
.RS .RS
.nf .nf
rofi \-fg "#222222" rofi \-bg "#222222"
.fi
.RE
.PP
\fB\fC\-bg\fR
.IP
Set the background text color for alternating rows (X11 named color or hex #rrggbb) for the menu
(default: #222222).
.PP
.RS
.nf
rofi \-bgalt "#222222"
.fi .fi
.RE .RE
.PP .PP

View file

@ -154,6 +154,8 @@ typedef struct _Settings
char * menu_fg; char * menu_fg;
/** Background color */ /** Background color */
char * menu_bg; char * menu_bg;
/** Background color alt */
char * menu_bg_alt;
/** Highlight foreground color */ /** Highlight foreground color */
char * menu_hlfg; char * menu_hlfg;
/** Highlight background color */ /** Highlight background color */

View file

@ -35,6 +35,8 @@ typedef enum
{ {
// Render font normally // Render font normally
NORMAL, NORMAL,
// Alternating row.
ALT,
// Render font highlighted (inverted colors.) // Render font highlighted (inverted colors.)
HIGHLIGHT, HIGHLIGHT,
} TextBoxFontType; } TextBoxFontType;
@ -132,9 +134,8 @@ void textbox_insert ( textbox *tb, int pos, char *str );
void textbox_hide ( textbox *tb ); void textbox_hide ( textbox *tb );
/** /**
* @param font_str The font to use.
* @param font_active_str The font to use for active entries.
* @param bg The background color. * @param bg The background color.
* @param bg_alt The background color for alternating row.
* @param fg The foreground color. * @param fg The foreground color.
* @param hlbg The background color for a highlighted entry. * @param hlbg The background color for a highlighted entry.
* @param hlfg The foreground color for a highlighted entry. * @param hlfg The foreground color for a highlighted entry.
@ -144,7 +145,7 @@ void textbox_hide ( textbox *tb );
* Clean with textbox_cleanup() * Clean with textbox_cleanup()
*/ */
void textbox_setup ( void textbox_setup (
const char *bg, const char *fg, const char *bg, const char *bg_alt, const char *fg,
const char *hlbg, const char *hlfg const char *hlbg, const char *hlfg
); );

View file

@ -1278,8 +1278,9 @@ static void menu_draw ( MenuState *state )
textbox_text ( state->boxes[i], "" ); textbox_text ( state->boxes[i], "" );
} }
else{ else{
TextBoxFontType type = ( ( ( i % state->max_rows ) & 1 ) == 0 ) ? NORMAL : ALT;
char *text = state->filtered[i + offset]; char *text = state->filtered[i + offset];
TextBoxFontType tbft = ( i + offset ) == state->selected ? HIGHLIGHT : NORMAL; TextBoxFontType tbft = ( i + offset ) == state->selected ? HIGHLIGHT : type;
textbox_font ( state->boxes[i], tbft ); textbox_font ( state->boxes[i], tbft );
textbox_text ( state->boxes[i], text ); textbox_text ( state->boxes[i], text );
} }
@ -1944,7 +1945,7 @@ static int run_dmenu ()
{ {
int ret_state; int ret_state;
textbox_setup ( textbox_setup (
config.menu_bg, config.menu_fg, config.menu_bg, config.menu_bg_alt, config.menu_fg,
config.menu_hlbg, config.menu_hlbg,
config.menu_hlfg ); config.menu_hlfg );
char *input = NULL; char *input = NULL;
@ -1977,7 +1978,7 @@ static void run_switcher ( int do_fork, SwitcherMode mode )
// Because of the above fork, we want to do this here. // Because of the above fork, we want to do this here.
// Make sure this is isolated to its own thread. // Make sure this is isolated to its own thread.
textbox_setup ( textbox_setup (
config.menu_bg, config.menu_fg, config.menu_bg, config.menu_bg_alt, config.menu_fg,
config.menu_hlbg, config.menu_hlbg,
config.menu_hlfg ); config.menu_hlfg );
char *input = NULL; char *input = NULL;
@ -2194,6 +2195,7 @@ static void parse_cmd_options ( int argc, char ** argv )
find_arg_str ( argc, argv, "-font", &( config.menu_font ) ); find_arg_str ( argc, argv, "-font", &( config.menu_font ) );
find_arg_str ( argc, argv, "-fg", &( config.menu_fg ) ); find_arg_str ( argc, argv, "-fg", &( config.menu_fg ) );
find_arg_str ( argc, argv, "-bg", &( config.menu_bg ) ); find_arg_str ( argc, argv, "-bg", &( config.menu_bg ) );
find_arg_str ( argc, argv, "-bgalt", &( config.menu_bg_alt ) );
find_arg_str ( argc, argv, "-hlfg", &( config.menu_hlfg ) ); find_arg_str ( argc, argv, "-hlfg", &( config.menu_hlfg ) );
find_arg_str ( argc, argv, "-hlbg", &( config.menu_hlbg ) ); find_arg_str ( argc, argv, "-hlbg", &( config.menu_hlbg ) );
find_arg_str ( argc, argv, "-bc", &( config.menu_bc ) ); find_arg_str ( argc, argv, "-bc", &( config.menu_bc ) );
@ -2245,11 +2247,6 @@ static void parse_cmd_options ( int argc, char ** argv )
if ( find_arg ( argc, argv, "-sidebar-mode" ) >= 0 ) { if ( find_arg ( argc, argv, "-sidebar-mode" ) >= 0 ) {
config.sidebar_mode = TRUE; config.sidebar_mode = TRUE;
} }
// Dump.
if ( find_arg ( argc, argv, "-dump-xresources" ) >= 0 ) {
xresource_dump ();
exit ( EXIT_SUCCESS );
}
} }
/** /**
@ -2322,6 +2319,10 @@ static void config_sanity_check ( void )
fprintf ( stderr, "config.hmode is invalid.\n" ); fprintf ( stderr, "config.hmode is invalid.\n" );
exit ( 1 ); exit ( 1 );
} }
// If alternative row is not set, copy the normal background color.
if ( config.menu_bg_alt == NULL ) {
config.menu_bg_alt = config.menu_bg;
}
} }
/** /**
@ -2452,6 +2453,12 @@ int main ( int argc, char *argv[] )
load_configuration ( display ); load_configuration ( display );
// Dump.
if ( find_arg ( argc, argv, "-dump-xresources" ) >= 0 ) {
xresource_dump ();
exit ( EXIT_SUCCESS );
}
// setup_switchers // setup_switchers
setup_switchers (); setup_switchers ();
@ -2491,7 +2498,7 @@ int main ( int argc, char *argv[] )
char *msg = NULL; char *msg = NULL;
if ( find_arg_str ( argc, argv, "-e", &( msg ) ) ) { if ( find_arg_str ( argc, argv, "-e", &( msg ) ) ) {
textbox_setup ( textbox_setup (
config.menu_bg, config.menu_fg, config.menu_bg, config.menu_bg_alt, config.menu_fg,
config.menu_hlbg, config.menu_hlbg,
config.menu_hlfg ); config.menu_hlfg );
error_dialog ( msg ); error_dialog ( msg );

View file

@ -54,6 +54,7 @@ XftColor color_fg;
XftColor color_bg; XftColor color_bg;
XftColor color_hlfg; XftColor color_hlfg;
XftColor color_hlbg; XftColor color_hlbg;
XftColor color_bg_alt;
PangoContext *p_context = NULL; PangoContext *p_context = NULL;
@ -83,7 +84,19 @@ textbox* textbox_create ( Window parent,
pango_layout_set_font_description ( tb->layout, pfd ); pango_layout_set_font_description ( tb->layout, pfd );
pango_font_description_free ( pfd ); pango_font_description_free ( pfd );
unsigned int cp = ( tbft == NORMAL ) ? color_bg.pixel : color_hlbg.pixel; unsigned int cp;
switch ( tbft )
{
case HIGHLIGHT:
cp = color_hlbg.pixel;
break;
case ALT:
cp = color_bg_alt.pixel;
break;
default:
cp = color_bg.pixel;
break;
}
tb->window = XCreateSimpleWindow ( display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, None, cp ); tb->window = XCreateSimpleWindow ( display, tb->parent, tb->x, tb->y, tb->w, tb->h, 0, None, cp );
@ -119,6 +132,10 @@ void textbox_font ( textbox *tb, TextBoxFontType tbft )
tb->color_bg = color_hlbg; tb->color_bg = color_hlbg;
tb->color_fg = color_hlfg; tb->color_fg = color_hlfg;
break; break;
case ALT:
tb->color_bg = color_bg_alt;
tb->color_fg = color_fg;
break;
case NORMAL: case NORMAL:
default: default:
tb->color_bg = color_bg; tb->color_bg = color_bg;
@ -432,7 +449,7 @@ int textbox_keypress ( textbox *tb, XEvent *ev )
*/ */
void textbox_setup ( void textbox_setup (
const char *bg, const char *fg, const char *bg, const char *bg_alt, const char *fg,
const char *hlbg, const char *hlfg const char *hlbg, const char *hlfg
) )
{ {
@ -441,6 +458,7 @@ void textbox_setup (
XftColorAllocName ( display, visual, colormap, fg, &color_fg ); XftColorAllocName ( display, visual, colormap, fg, &color_fg );
XftColorAllocName ( display, visual, colormap, bg, &color_bg ); XftColorAllocName ( display, visual, colormap, bg, &color_bg );
XftColorAllocName ( display, visual, colormap, bg_alt, &color_bg_alt );
XftColorAllocName ( display, visual, colormap, hlfg, &color_hlfg ); XftColorAllocName ( display, visual, colormap, hlfg, &color_hlfg );
XftColorAllocName ( display, visual, colormap, hlbg, &color_hlbg ); XftColorAllocName ( display, visual, colormap, hlbg, &color_hlbg );
@ -458,6 +476,7 @@ void textbox_cleanup ()
XftColorFree ( display, visual, colormap, &color_fg ); XftColorFree ( display, visual, colormap, &color_fg );
XftColorFree ( display, visual, colormap, &color_bg ); XftColorFree ( display, visual, colormap, &color_bg );
XftColorFree ( display, visual, colormap, &color_bg_alt );
XftColorFree ( display, visual, colormap, &color_hlfg ); XftColorFree ( display, visual, colormap, &color_hlfg );
XftColorFree ( display, visual, colormap, &color_hlbg ); XftColorFree ( display, visual, colormap, &color_hlbg );
g_object_unref ( p_context ); g_object_unref ( p_context );

View file

@ -60,57 +60,59 @@ typedef struct
* Currently supports string and number. * Currently supports string and number.
*/ */
static XrmOption xrmOptions[] = { static XrmOption xrmOptions[] = {
{ xrm_String, "switchers", { .str = &config.switchers }, NULL }, { xrm_String, "switchers", { .str = &config.switchers }, NULL },
{ xrm_Number, "opacity", { .num = &config.window_opacity }, NULL }, { xrm_Number, "opacity", { .num = &config.window_opacity }, NULL },
{ xrm_SNumber, "width", { .snum = &config.menu_width }, NULL }, { xrm_SNumber, "width", { .snum = &config.menu_width }, NULL },
{ xrm_Number, "lines", { .num = &config.menu_lines }, NULL }, { xrm_Number, "lines", { .num = &config.menu_lines }, NULL },
{ xrm_Number, "columns", { .num = &config.menu_columns }, NULL }, { xrm_Number, "columns", { .num = &config.menu_columns }, NULL },
{ xrm_String, "font", { .str = &config.menu_font }, NULL }, { xrm_String, "font", { .str = &config.menu_font }, NULL },
/* Foreground color */ /* Foreground color */
{ xrm_String, "foreground", { .str = &config.menu_fg }, NULL }, { xrm_String, "foreground", { .str = &config.menu_fg }, NULL },
{ xrm_String, "fg", { .str = &config.menu_fg }, NULL }, { xrm_String, "fg", { .str = &config.menu_fg }, NULL },
{ xrm_String, "background", { .str = &config.menu_bg }, NULL }, { xrm_String, "background", { .str = &config.menu_bg }, NULL },
{ xrm_String, "bg", { .str = &config.menu_bg }, NULL }, { xrm_String, "bg", { .str = &config.menu_bg }, 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, "highlightfg", { .str = &config.menu_hlfg }, NULL },
{ xrm_String, "hlfg", { .str = &config.menu_hlfg }, NULL }, { xrm_String, "hlfg", { .str = &config.menu_hlfg }, NULL },
{ xrm_String, "highlightbg", { .str = &config.menu_hlbg }, NULL }, { xrm_String, "highlightbg", { .str = &config.menu_hlbg }, NULL },
{ xrm_String, "hlbg", { .str = &config.menu_hlbg }, NULL }, { xrm_String, "hlbg", { .str = &config.menu_hlbg }, NULL },
{ xrm_String, "bordercolor", { .str = &config.menu_bc }, NULL }, { xrm_String, "bordercolor", { .str = &config.menu_bc }, NULL },
{ xrm_String, "bc", { .str = &config.menu_bc }, NULL }, { xrm_String, "bc", { .str = &config.menu_bc }, NULL },
{ xrm_Number, "borderwidth", { .num = &config.menu_bw }, NULL }, { xrm_Number, "borderwidth", { .num = &config.menu_bw }, NULL },
{ xrm_Number, "bw", { .num = &config.menu_bw }, NULL }, { xrm_Number, "bw", { .num = &config.menu_bw }, NULL },
{ xrm_Number, "location", { .num = &config.location }, NULL }, { xrm_Number, "location", { .num = &config.location }, NULL },
{ xrm_Number, "padding", { .num = &config.padding }, NULL }, { xrm_Number, "padding", { .num = &config.padding }, NULL },
{ xrm_SNumber, "yoffset", { .snum = &config.y_offset }, NULL }, { xrm_SNumber, "yoffset", { .snum = &config.y_offset }, NULL },
{ xrm_SNumber, "xoffset", { .snum = &config.x_offset }, NULL }, { xrm_SNumber, "xoffset", { .snum = &config.x_offset }, NULL },
{ xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines }, NULL }, { xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines }, NULL },
{ xrm_Boolean, "hmode", { .num = &config.hmode }, NULL }, { xrm_Boolean, "hmode", { .num = &config.hmode }, NULL },
{ xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL }, { xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL },
{ xrm_String, "ssh-client", { .str = &config.ssh_client }, NULL }, { xrm_String, "ssh-client", { .str = &config.ssh_client }, NULL },
{ xrm_String, "ssh-command", { .str = &config.ssh_command }, NULL }, { xrm_String, "ssh-command", { .str = &config.ssh_command }, NULL },
{ xrm_String, "run-command", { .str = &config.run_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-list-command", { .str = &config.run_list_command }, NULL },
{ xrm_String, "run-shell-command", { .str = &config.run_shell_command }, NULL }, { xrm_String, "run-shell-command", { .str = &config.run_shell_command }, NULL },
{ xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL }, { xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL },
{ xrm_Boolean, "levenshtein-sort", { .num = &config.levenshtein_sort }, NULL }, { xrm_Boolean, "levenshtein-sort", { .num = &config.levenshtein_sort }, NULL },
/* Key bindings */ /* Key bindings */
{ xrm_String, "key", { .str = &config.window_key }, NULL }, { xrm_String, "key", { .str = &config.window_key }, NULL },
{ xrm_String, "rkey", { .str = &config.run_key }, NULL }, { xrm_String, "rkey", { .str = &config.run_key }, NULL },
{ xrm_String, "skey", { .str = &config.ssh_key }, NULL }, { xrm_String, "skey", { .str = &config.ssh_key }, NULL },
{ xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL } { xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL }
}; };

View file

@ -49,7 +49,7 @@ int main ( int argc, char **argv )
color_get ( display, config.menu_bg ) ); color_get ( display, config.menu_bg ) );
TASSERT( mw != None ); TASSERT( mw != None );
textbox_setup ( config.menu_bg, config.menu_fg, textbox_setup ( config.menu_bg, config.menu_bg_alt, config.menu_fg,
config.menu_hlbg, config.menu_hlfg ); config.menu_hlbg, config.menu_hlfg );
textbox *box = textbox_create(mw , TB_EDITABLE|TB_AUTOWIDTH|TB_AUTOHEIGHT, 0,0, -1, -1, NORMAL, "test"); textbox *box = textbox_create(mw , TB_EDITABLE|TB_AUTOWIDTH|TB_AUTOHEIGHT, 0,0, -1, -1, NORMAL, "test");
TASSERT( box != NULL ); TASSERT( box != NULL );