@ -55,117 +55,42 @@ char *parse_font(const char *font) {
static void ipc_parse_colors (
static void ipc_parse_colors (
struct swaybar_config * config , json_object * colors ) {
struct swaybar_config * config , json_object * colors ) {
json_object * background , * statusline , * separator ;
struct {
json_object * focused_background , * focused_statusline , * focused_separator ;
const char * name ;
json_object * focused_workspace_border , * focused_workspace_bg , * focused_workspace_text ;
uint32_t * color ;
json_object * inactive_workspace_border , * inactive_workspace_bg , * inactive_workspace_text ;
} properties [ ] = {
json_object * active_workspace_border , * active_workspace_bg , * active_workspace_text ;
{ " background " , & config - > colors . background } ,
json_object * urgent_workspace_border , * urgent_workspace_bg , * urgent_workspace_text ;
{ " statusline " , & config - > colors . statusline } ,
json_object * binding_mode_border , * binding_mode_bg , * binding_mode_text ;
{ " separator " , & config - > colors . separator } ,
json_object_object_get_ex ( colors , " background " , & background ) ;
{ " focused_background " , & config - > colors . focused_background } ,
json_object_object_get_ex ( colors , " statusline " , & statusline ) ;
{ " focused_statusline " , & config - > colors . focused_statusline } ,
json_object_object_get_ex ( colors , " separator " , & separator ) ;
{ " focused_separator " , & config - > colors . focused_separator } ,
json_object_object_get_ex ( colors , " focused_background " , & focused_background ) ;
{ " focused_workspace_border " , & config - > colors . focused_workspace . border } ,
json_object_object_get_ex ( colors , " focused_statusline " , & focused_statusline ) ;
{ " focused_workspace_bg " , & config - > colors . focused_workspace . background } ,
json_object_object_get_ex ( colors , " focused_separator " , & focused_separator ) ;
{ " focused_workspace_text " , & config - > colors . focused_workspace . text } ,
json_object_object_get_ex ( colors , " focused_workspace_border " , & focused_workspace_border ) ;
{ " active_workspace_border " , & config - > colors . active_workspace . border } ,
json_object_object_get_ex ( colors , " focused_workspace_bg " , & focused_workspace_bg ) ;
{ " active_workspace_bg " , & config - > colors . active_workspace . background } ,
json_object_object_get_ex ( colors , " focused_workspace_text " , & focused_workspace_text ) ;
{ " active_workspace_text " , & config - > colors . active_workspace . text } ,
json_object_object_get_ex ( colors , " active_workspace_border " , & active_workspace_border ) ;
{ " inactive_workspace_border " , & config - > colors . inactive_workspace . border } ,
json_object_object_get_ex ( colors , " active_workspace_bg " , & active_workspace_bg ) ;
{ " inactive_workspace_bg " , & config - > colors . inactive_workspace . background } ,
json_object_object_get_ex ( colors , " active_workspace_text " , & active_workspace_text ) ;
{ " inactive_workspace_text " , & config - > colors . inactive_workspace . text } ,
json_object_object_get_ex ( colors , " inactive_workspace_border " , & inactive_workspace_border ) ;
{ " urgent_workspace_border " , & config - > colors . urgent_workspace . border } ,
json_object_object_get_ex ( colors , " inactive_workspace_bg " , & inactive_workspace_bg ) ;
{ " urgent_workspace_bg " , & config - > colors . urgent_workspace . background } ,
json_object_object_get_ex ( colors , " inactive_workspace_text " , & inactive_workspace_text ) ;
{ " urgent_workspace_text " , & config - > colors . urgent_workspace . text } ,
json_object_object_get_ex ( colors , " urgent_workspace_border " , & urgent_workspace_border ) ;
{ " binding_mode_border " , & config - > colors . binding_mode . border } ,
json_object_object_get_ex ( colors , " urgent_workspace_bg " , & urgent_workspace_bg ) ;
{ " binding_mode_bg " , & config - > colors . binding_mode . background } ,
json_object_object_get_ex ( colors , " urgent_workspace_text " , & urgent_workspace_text ) ;
{ " binding_mode_text " , & config - > colors . binding_mode . text } ,
json_object_object_get_ex ( colors , " binding_mode_border " , & binding_mode_border ) ;
} ;
json_object_object_get_ex ( colors , " binding_mode_bg " , & binding_mode_bg ) ;
json_object_object_get_ex ( colors , " binding_mode_text " , & binding_mode_text ) ;
for ( size_t i = 0 ; i < sizeof ( properties ) / sizeof ( properties [ i ] ) ; i + + ) {
if ( background ) {
json_object * object ;
config - > colors . background = parse_color (
if ( json_object_object_get_ex ( colors , properties [ i ] . name , & object ) ) {
json_object_get_string ( background ) ) ;
const char * hexstring = json_object_get_string ( object ) ;
}
if ( ! parse_color ( hexstring , properties [ i ] . color ) ) {
if ( statusline ) {
sway_log ( SWAY_ERROR , " Ignoring invalid %s: %s " ,
config - > colors . statusline = parse_color (
properties [ i ] . name , hexstring ) ;
json_object_get_string ( statusline ) ) ;
}
}
}
if ( separator ) {
config - > colors . separator = parse_color (
json_object_get_string ( separator ) ) ;
}
if ( focused_background ) {
config - > colors . focused_background = parse_color (
json_object_get_string ( focused_background ) ) ;
}
if ( focused_statusline ) {
config - > colors . focused_statusline = parse_color (
json_object_get_string ( focused_statusline ) ) ;
}
if ( focused_separator ) {
config - > colors . focused_separator = parse_color (
json_object_get_string ( focused_separator ) ) ;
}
if ( focused_workspace_border ) {
config - > colors . focused_workspace . border = parse_color (
json_object_get_string ( focused_workspace_border ) ) ;
}
if ( focused_workspace_bg ) {
config - > colors . focused_workspace . background = parse_color (
json_object_get_string ( focused_workspace_bg ) ) ;
}
if ( focused_workspace_text ) {
config - > colors . focused_workspace . text = parse_color (
json_object_get_string ( focused_workspace_text ) ) ;
}
if ( active_workspace_border ) {
config - > colors . active_workspace . border = parse_color (
json_object_get_string ( active_workspace_border ) ) ;
}
if ( active_workspace_bg ) {
config - > colors . active_workspace . background = parse_color (
json_object_get_string ( active_workspace_bg ) ) ;
}
if ( active_workspace_text ) {
config - > colors . active_workspace . text = parse_color (
json_object_get_string ( active_workspace_text ) ) ;
}
if ( inactive_workspace_border ) {
config - > colors . inactive_workspace . border = parse_color (
json_object_get_string ( inactive_workspace_border ) ) ;
}
if ( inactive_workspace_bg ) {
config - > colors . inactive_workspace . background = parse_color (
json_object_get_string ( inactive_workspace_bg ) ) ;
}
if ( inactive_workspace_text ) {
config - > colors . inactive_workspace . text = parse_color (
json_object_get_string ( inactive_workspace_text ) ) ;
}
if ( urgent_workspace_border ) {
config - > colors . urgent_workspace . border = parse_color (
json_object_get_string ( urgent_workspace_border ) ) ;
}
if ( urgent_workspace_bg ) {
config - > colors . urgent_workspace . background = parse_color (
json_object_get_string ( urgent_workspace_bg ) ) ;
}
if ( urgent_workspace_text ) {
config - > colors . urgent_workspace . text = parse_color (
json_object_get_string ( urgent_workspace_text ) ) ;
}
if ( binding_mode_border ) {
config - > colors . binding_mode . border = parse_color (
json_object_get_string ( binding_mode_border ) ) ;
}
if ( binding_mode_bg ) {
config - > colors . binding_mode . background = parse_color (
json_object_get_string ( binding_mode_bg ) ) ;
}
if ( binding_mode_text ) {
config - > colors . binding_mode . text = parse_color (
json_object_get_string ( binding_mode_text ) ) ;
}
}
}
}