@ -367,7 +367,7 @@ bool ipc_initialize(struct swaybar *bar) {
struct swaybar_config * config = bar - > config ;
struct swaybar_config * config = bar - > config ;
char subscribe [ 128 ] ; // suitably large buffer
char subscribe [ 128 ] ; // suitably large buffer
len = snprintf ( subscribe , 128 ,
len = snprintf ( subscribe , 128 ,
" [ \" barconfig_update \" %s %s ]" ,
" [ \" barconfig_update \" , \" bar_state_update \" %s %s ]" ,
config - > binding_mode_indicator ? " , \" mode \" " : " " ,
config - > binding_mode_indicator ? " , \" mode \" " : " " ,
config - > workspace_buttons ? " , \" workspace \" " : " " ) ;
config - > workspace_buttons ? " , \" workspace \" " : " " ) ;
free ( ipc_single_command ( bar - > ipc_event_socketfd ,
free ( ipc_single_command ( bar - > ipc_event_socketfd ,
@ -375,6 +375,20 @@ bool ipc_initialize(struct swaybar *bar) {
return true ;
return true ;
}
}
static bool handle_bar_state_update ( struct swaybar * bar , json_object * event ) {
json_object * json_id ;
json_object_object_get_ex ( event , " id " , & json_id ) ;
const char * id = json_object_get_string ( json_id ) ;
if ( strcmp ( id , bar - > id ) ! = 0 ) {
return false ;
}
json_object * visible_by_modifier ;
json_object_object_get_ex ( event , " visible_by_modifier " , & visible_by_modifier ) ;
bar - > visible_by_modifier = json_object_get_boolean ( visible_by_modifier ) ;
return determine_bar_visibility ( bar , false ) ;
}
static bool handle_barconfig_update ( struct swaybar * bar ,
static bool handle_barconfig_update ( struct swaybar * bar ,
json_object * json_config ) {
json_object * json_config ) {
json_object * json_id ;
json_object * json_id ;
@ -444,6 +458,9 @@ bool handle_ipc_readable(struct swaybar *bar) {
case IPC_EVENT_BARCONFIG_UPDATE :
case IPC_EVENT_BARCONFIG_UPDATE :
bar_is_dirty = handle_barconfig_update ( bar , result ) ;
bar_is_dirty = handle_barconfig_update ( bar , result ) ;
break ;
break ;
case IPC_EVENT_BAR_STATE_UPDATE :
bar_is_dirty = handle_bar_state_update ( bar , result ) ;
break ;
default :
default :
bar_is_dirty = false ;
bar_is_dirty = false ;
break ;
break ;