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

Re-enable background/foreground. Make theming method an option.

This commit is contained in:
QC 2015-04-11 12:04:14 +02:00
parent 27dfb8937d
commit c1a8735e24
7 changed files with 77 additions and 67 deletions

View file

@ -47,34 +47,36 @@ Settings config = {
/** Font */
.menu_font = "mono 12",
/** Background color */
.menu_bg = NULL,
/** Border color. */
.menu_bc = NULL,
/** Row colors */
// Enable new color
.color_enabled = FALSE,
.color_normal = "#fdf6e3,#002b36,#eee8d5,#586e75,#eee8d5",
.color_urgent = "#fdf6e3,#dc322f,#eee8d5,#dc322f,#fdf6e3",
.color_active = "#fdf6e3,#268bd2,#eee8d5,#268bd2,#fdf6e3",
.color_window = "#fdf6e3,#002b36",
/** Background color */
.menu_bg = "#FDF6E3",
/** Border color. */
.menu_bc = "#002B36",
/** Foreground color */
.menu_fg = NULL,
.menu_fg = "#002B36",
/** Text color used for urgent windows */
.menu_fg_urgent = NULL,
.menu_fg_urgent = "#DC322F",
/** Text color used for active window */
.menu_fg_active = NULL,
.menu_bg_urgent = NULL,
.menu_bg_active = NULL,
.menu_fg_active = "#268BD2",
.menu_bg_urgent = "#FDF6E3",
.menu_bg_active = "#FDF6E3",
/** Background color alternate row */
.menu_bg_alt = NULL,
.menu_bg_alt = "#EEE8D5",
/** Foreground color (selected) */
.menu_hlfg = NULL,
.menu_hlfg_urgent = NULL,
.menu_hlfg_active = NULL,
.menu_hlfg = "#EEE8D5",
.menu_hlfg_urgent = "#FDF6E3",
.menu_hlfg_active = "#FDF6E3",
/** Background color (selected) */
.menu_hlbg = NULL,
.menu_hlbg_urgent = NULL,
.menu_hlbg_active = NULL,
.menu_hlbg = "#586E75",
.menu_hlbg_urgent = "#DC322F",
.menu_hlbg_active = "#268BD2",
/** Terminal to use. (for ssh and open in terminal) */
.terminal_emulator = "x-terminal-emulator",
.ssh_client = "ssh",

View file

@ -506,8 +506,9 @@ override xresources).
## Theming
With **rofi** 0.15.4 we have a new way of specifying colors, the old settings still apply (for now)
and override the new setup. The new setup allows you to specify colors per state, similar to **i3**
With **rofi** 0.15.4 we have a new way of specifying colors, the old settings still apply (for now).
To enable the new setup, set `rofi.color-enabled` to true. The new setup allows you to specify
colors per state, similar to **i3**
Currently 3 states exists:
* **normal** Normal row.
@ -527,7 +528,7 @@ a pair `background,border`.
An example for `Xresources` file:
```
! State: 'bg', 'fg', 'bgalt', 'hlfg', 'hlbg'
! State: 'bg', 'fg', 'bgalt', 'hlbg', 'hlfg'
rofi.color-normal: #fdf6e3, #002b36, #eee8d5, #586e75, #eee8d5
rofi.color-urgent: #fdf6e3, #dc322f, #eee8d5, #dc322f, #fdf6e3
rofi.color-active: #fdf6e3, #268bd2, #eee8d5, #268bd2, #fdf6e3

View file

@ -633,8 +633,9 @@ If in daemon mode, reload the configuration from Xresources. (commandline argume
override xresources).
.SH Theming
.PP
With \fBrofi\fP 0.15.4 we have a new way of specifying colors, the old settings still apply (for now)
and override the new setup. The new setup allows you to specify colors per state, similar to \fBi3\fP
With \fBrofi\fP 0.15.4 we have a new way of specifying colors, the old settings still apply (for now).
To enable the new setup, set \fB\fCrofi.color\-enabled\fR to true. The new setup allows you to specify
colors per state, similar to \fBi3\fP
Currently 3 states exists:
.RS
.IP \(bu 2
@ -666,7 +667,7 @@ An example for \fB\fCXresources\fR file:
.PP
.RS
.nf
! State: 'bg', 'fg', 'bgalt', 'hlfg', 'hlbg'
! State: 'bg', 'fg', 'bgalt', 'hlbg', 'hlfg'
rofi.color\-normal: #fdf6e3, #002b36, #eee8d5, #586e75, #eee8d5
rofi.color\-urgent: #fdf6e3, #dc322f, #eee8d5, #dc322f, #fdf6e3
rofi.color\-active: #fdf6e3, #268bd2, #eee8d5, #268bd2, #fdf6e3

View file

@ -154,6 +154,7 @@ typedef struct _Settings
char * menu_font;
/** New row colors */
unsigned int color_enabled;
char * color_normal;
char * color_active;
char * color_urgent;

View file

@ -621,7 +621,6 @@ static void parse_color ( Visual *visual, Colormap colormap,
XftColorAllocName ( display, visual, colormap, bg, color );
}
}
#if 1
static void textbox_parse_string ( XVisualInfo *visual, Colormap colormap, const char *str, RowColor *color )
{
if ( str == NULL ) {
@ -654,19 +653,20 @@ static void textbox_parse_string ( XVisualInfo *visual, Colormap colormap, const
}
g_free ( cstr );
}
#endif
void textbox_setup ( XVisualInfo *visual, Colormap colormap )
{
visual_info = visual;
target_colormap = colormap;
if ( config.color_enabled ) {
textbox_parse_string ( visual, target_colormap,
config.color_normal, &( colors[NORMAL] ) );
textbox_parse_string ( visual, target_colormap,
config.color_urgent, &( colors[URGENT] ) );
textbox_parse_string ( visual, target_colormap,
config.color_active, &( colors[ACTIVE] ) );
#if 1
}
else {
parse_color ( visual_info->visual, target_colormap, config.menu_bg, &( colors[NORMAL].bg ) );
parse_color ( visual_info->visual, target_colormap, config.menu_fg, &( colors[NORMAL].fg ) );
parse_color ( visual_info->visual, target_colormap, config.menu_bg_alt, &( colors[NORMAL].bgalt ) );
@ -684,7 +684,7 @@ void textbox_setup ( XVisualInfo *visual, Colormap colormap )
parse_color ( visual_info->visual, target_colormap, config.menu_bg_alt, &( colors[ACTIVE].bgalt ) );
parse_color ( visual_info->visual, target_colormap, config.menu_hlfg_active, &( colors[ACTIVE].hlfg ) );
parse_color ( visual_info->visual, target_colormap, config.menu_hlbg_active, &( colors[ACTIVE].hlbg ) );
#endif
}
PangoFontMap *font_map = pango_xft_get_font_map ( display, DefaultScreen ( display ) );
p_context = pango_font_map_create_context ( font_map );
}

View file

@ -447,9 +447,10 @@ unsigned int color_get ( Display *display, const char *const name )
unsigned int color_background ( Display *display )
{
if ( config.menu_bg ) {
if ( !config.color_enabled ) {
return color_get ( display, config.menu_bg );
}
else {
unsigned int retv = 0;
gchar **vals = g_strsplit ( config.color_window, ",", 2 );
@ -458,13 +459,15 @@ unsigned int color_background ( Display *display )
}
g_strfreev ( vals );
return retv;
}
}
unsigned int color_border ( Display *display )
{
if ( config.menu_bc ) {
if ( !config.color_enabled ) {
return color_get ( display, config.menu_bc );
}
else {
unsigned int retv = 0;
gchar **vals = g_strsplit ( config.color_window, ",", 2 );
@ -473,4 +476,5 @@ unsigned int color_border ( Display *display )
}
g_strfreev ( vals );
return retv;
}
}

View file

@ -64,11 +64,12 @@ static XrmOption xrmOptions[] = {
{ xrm_String, "font", { .str = &config.menu_font }, NULL },
/* 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, "background", { .str = &config.menu_bg }, NULL },*/
{ xrm_String, "background", { .str = &config.menu_bg }, NULL },
{ xrm_String, "bg", { .str = &config.menu_bg }, NULL },
{ xrm_Boolean, "color-enabled", { .num = &config.color_enabled }, NULL },
{ 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 },