mirror of
https://github.com/FelixKratz/SketchyBar
synced 2024-11-22 19:33:03 +00:00
getting scripts to work
This commit is contained in:
parent
75f23cbaa7
commit
a6a5846f48
5 changed files with 24 additions and 0 deletions
|
@ -7,6 +7,7 @@ struct bar_item* bar_item_create() {
|
|||
}
|
||||
|
||||
void bar_item_init(struct bar_item* bar_item) {
|
||||
bar_item->counter = 0;
|
||||
bar_item->name = "";
|
||||
bar_item->type = BAR_ITEM;
|
||||
bar_item->update_frequency = 5;
|
||||
|
@ -28,6 +29,19 @@ void bar_item_init(struct bar_item* bar_item) {
|
|||
bar_item->label_color = rgba_color_from_hex(0xffffffff);
|
||||
}
|
||||
|
||||
void bar_item_script_update(struct bar_item* bar_item) {
|
||||
if (strcmp(bar_item->script, "") != 0) {
|
||||
if (bar_item->update_frequency <= bar_item->counter) {
|
||||
bar_item->counter = 0;
|
||||
}
|
||||
else {
|
||||
bar_item->counter++;
|
||||
return;
|
||||
}
|
||||
fork_exec(bar_item->script, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void bar_item_update_component(struct bar_item* bar_item, uint32_t did, uint32_t sid) {
|
||||
if (bar_item->type == BAR_COMPONENT) {
|
||||
if (strcmp(bar_item->identifier, "title") == 0) {
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define BAR_POSITION_CENTER 'c'
|
||||
|
||||
struct bar_item {
|
||||
int counter;
|
||||
char type;
|
||||
char* identifier;
|
||||
|
||||
|
@ -54,6 +55,7 @@ struct bar_item {
|
|||
};
|
||||
|
||||
struct bar_item* bar_item_create();
|
||||
void bar_item_script_update(struct bar_item* bar_item);
|
||||
void bar_item_update_component(struct bar_item* bar_item, uint32_t did, uint32_t sid);
|
||||
void bar_item_init(struct bar_item* bar_item);
|
||||
void bar_item_set_name(struct bar_item* bar_item, char* name);
|
||||
|
|
|
@ -121,6 +121,12 @@ void bar_manager_update_components(struct bar_manager* bar_manager, uint32_t did
|
|||
}
|
||||
}
|
||||
|
||||
void bar_manager_script_update(struct bar_manager* bar_manager) {
|
||||
for (int i = 0; i < bar_manager->bar_item_count; i++) {
|
||||
bar_item_script_update(bar_manager->bar_items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void bar_manager_begin(struct bar_manager *bar_manager)
|
||||
{
|
||||
char * main = "main";
|
||||
|
|
|
@ -23,6 +23,7 @@ struct bar_manager
|
|||
int bar_manager_get_item_index_for_name(struct bar_manager* bar_manager, char* name);
|
||||
struct bar_item* bar_manager_create_item(struct bar_manager* bar_manager);
|
||||
|
||||
void bar_manager_script_update(struct bar_manager* bar_manager);
|
||||
void bar_manager_update_components(struct bar_manager* bar_manager, uint32_t did, uint32_t sid);
|
||||
void bar_manager_set_foreground_color(struct bar_manager *bar_manager, uint32_t color);
|
||||
void bar_manager_set_background_color(struct bar_manager *bar_manager, uint32_t color);
|
||||
|
|
|
@ -213,6 +213,7 @@ static EVENT_CALLBACK(EVENT_HANDLER_BAR_REFRESH)
|
|||
|
||||
static EVENT_CALLBACK(EVENT_HANDLER_SHELL_REFRESH)
|
||||
{
|
||||
bar_manager_script_update(&g_bar_manager);
|
||||
return EVENT_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue