diff --git a/doc/tint2.md b/doc/tint2.md index af52798..aa70da4 100644 --- a/doc/tint2.md +++ b/doc/tint2.md @@ -621,6 +621,8 @@ The action semantics: * `execp_padding = horizontal_padding vertical_padding spacing_between_icon_and_text` *(since 0.12.4)* + * `execp_monitor = integer (1, 2, ...), primary or all` : On which monitor to draw the executor. The first monitor is `1`. *(since 17.0)* + * `execp_lclick_command = text` : Command to execute on left click. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.12.4)* * `execp_mclick_command = text` : Command to execute on right click. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.12.4)* * `execp_rclick_command = text` : Command to execute on middle click. If not defined, `execp_command` is executed immediately, unless it is currently running. *(since 0.12.4)* diff --git a/src/config.c b/src/config.c index b23857c..d74d70a 100644 --- a/src/config.c +++ b/src/config.c @@ -697,6 +697,9 @@ void add_entry(char *key, char *value) } else { execp->backend->interval = v; } + } else if (strcmp(key, "execp_monitor") == 0) { + Execp *execp = get_or_create_last_execp(); + execp->backend->monitor = config_get_monitor(value); } else if (strcmp(key, "execp_has_icon") == 0) { Execp *execp = get_or_create_last_execp(); execp->backend->has_icon = atoi(value); diff --git a/src/execplugin/execplugin.c b/src/execplugin/execplugin.c index 71394b1..caa768f 100644 --- a/src/execplugin/execplugin.c +++ b/src/execplugin/execplugin.c @@ -43,6 +43,7 @@ Execp *create_execp() execp->backend->cache_icon = TRUE; execp->backend->centered = TRUE; execp->backend->font_color.alpha = 0.5; + execp->backend->monitor = -1; INIT_TIMER(execp->backend->timer); return execp; } @@ -50,6 +51,17 @@ Execp *create_execp() gpointer create_execp_frontend(gconstpointer arg, gpointer data) { Execp *execp_backend = (Execp *)arg; + Panel *panel = data; + if (execp_backend->backend->monitor >= 0 && + panel->monitor != execp_backend->backend->monitor) { + printf("Skipping executor '%s' with monitor %d for panel on monitor %d\n", + execp_backend->backend->command, + execp_backend->backend->monitor, panel->monitor); + return NULL; + } + printf("Creating executor '%s' with monitor %d for panel on monitor %d\n", + execp_backend->backend->command, + execp_backend->backend->monitor, panel->monitor); Execp *execp_frontend = (Execp *)calloc(1, sizeof(Execp)); execp_frontend->backend = execp_backend->backend; @@ -163,7 +175,8 @@ void init_execp_panel(void *p) // panel->execp_list is now a copy of the pointer panel_config.execp_list // We make it a deep copy - panel->execp_list = g_list_copy_deep(panel_config.execp_list, create_execp_frontend, NULL); + panel->execp_list = g_list_copy_deep(panel_config.execp_list, create_execp_frontend, panel); + panel->execp_list = g_list_remove_all(panel->execp_list, NULL); for (GList *l = panel->execp_list; l; l = l->next) { Execp *execp = l->data; diff --git a/src/execplugin/execplugin.h b/src/execplugin/execplugin.h index bb186bd..127d12f 100644 --- a/src/execplugin/execplugin.h +++ b/src/execplugin/execplugin.h @@ -24,6 +24,7 @@ typedef struct ExecpBackend { char *command; // Interval in seconds int interval; + int monitor; // 1 if first line of output is an icon path gboolean has_icon; gboolean cache_icon; diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index 723ce5f..430b590 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -4374,6 +4374,31 @@ void create_execp(GtkWidget *notebook, int i) "that print data downloaded from the Internet is a potential security risk."), NULL); + row++, col = 2; + label = gtk_label_new(_("Monitor")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_widget_show(label); + gtk_table_attach(GTK_TABLE(table), label, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + + executor->execp_monitor = gtk_combo_box_text_new(); + gtk_widget_show(executor->execp_monitor); + gtk_table_attach(GTK_TABLE(table), executor->execp_monitor, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0); + col++; + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("All")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("Primary")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("1")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("2")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("3")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("4")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("5")); + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(executor->execp_monitor), _("6")); + gtk_combo_box_set_active(GTK_COMBO_BOX(executor->execp_monitor), 0); + gtk_tooltips_set_tip(tooltips, + executor->execp_monitor, + _("Specifies the monitor on which to place the executor."), + NULL); + change_paragraph(parent); label = gtk_label_new(_("Mouse events")); diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h index 4c5dc35..58ec508 100644 --- a/src/tint2conf/properties.h +++ b/src/tint2conf/properties.h @@ -133,7 +133,7 @@ typedef struct Executor { GtkWidget *page_execp; GtkWidget *page_label; GtkWidget *execp_command, *execp_interval, *execp_has_icon, *execp_cache_icon, *execp_show_tooltip; - GtkWidget *execp_continuous, *execp_markup, *execp_tooltip; + GtkWidget *execp_continuous, *execp_markup, *execp_tooltip, *execp_monitor; GtkWidget *execp_left_command, *execp_right_command; GtkWidget *execp_mclick_command, *execp_rclick_command, *execp_uwheel_command, *execp_dwheel_command; GtkWidget *execp_font, *execp_font_set, *execp_font_color, *execp_padding_x, *execp_padding_y, *execp_centered; diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c index 622ee74..492a2b8 100644 --- a/src/tint2conf/properties_rw.c +++ b/src/tint2conf/properties_rw.c @@ -871,6 +871,16 @@ void config_write_execp(FILE *fp) fprintf(fp, "execp_markup = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_markup)) ? 1 : 0); + fprintf(fp, "execp_monitor = "); + if (gtk_combo_box_get_active(GTK_COMBO_BOX(executor->execp_monitor)) <= 0) { + fprintf(fp, "all"); + } else if (gtk_combo_box_get_active(GTK_COMBO_BOX(executor->execp_monitor)) == 1) { + fprintf(fp, "primary"); + } else { + fprintf(fp, "%d", MAX(1, gtk_combo_box_get_active(GTK_COMBO_BOX(executor->execp_monitor)) - 1)); + } + fprintf(fp, "\n"); + if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_show_tooltip))) { fprintf(fp, "execp_tooltip = \n"); } else { @@ -1964,6 +1974,23 @@ void add_entry(char *key, char *value) gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_continuous), atoi(value)); } else if (strcmp(key, "execp_markup") == 0) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_markup), atoi(value)); + } else if (strcmp(key, "execp_monitor") == 0) { + if (strcmp(value, "all") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 0); + else if (strcmp(value, "primary") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 1); + else if (strcmp(value, "1") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 2); + else if (strcmp(value, "2") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 3); + else if (strcmp(value, "3") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 4); + else if (strcmp(value, "4") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 5); + else if (strcmp(value, "5") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 6); + else if (strcmp(value, "6") == 0) + gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_monitor), 7); } else if (strcmp(key, "execp_tooltip") == 0) { if (strlen(value) > 0) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_show_tooltip), 1);