all repos — tint2 @ 701b57e1135a4f38af065fbbe32caf669f5a0b98

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Open current tint2 config automatically when started from tint2
o9000 mrovi9000@gmail.com
commit

701b57e1135a4f38af065fbbe32caf669f5a0b98

parent

affac4cfa6b1f1393070f60ad3173cd1da1e6ed0

M src/battery/battery.csrc/battery/battery.c

@@ -227,14 +227,14 @@ }

if (old_ac_connected != battery_state.ac_connected) { if (battery_state.ac_connected) - tint_exec(ac_connected_cmd); + tint_exec_no_sn(ac_connected_cmd); else - tint_exec(ac_disconnected_cmd); + tint_exec_no_sn(ac_disconnected_cmd); } if (battery_state.percentage < battery_low_status && battery_state.state == BATTERY_DISCHARGING && !battery_low_cmd_sent) { - tint_exec(battery_low_cmd); + tint_exec_no_sn(battery_low_cmd); battery_low_cmd_sent = TRUE; } if (battery_state.percentage > battery_low_status && battery_state.state == BATTERY_CHARGING &&

@@ -437,7 +437,7 @@ {

return battery_os_tooltip(); } -void battery_action(int button) +void battery_action(int button, Time time) { char *command = NULL; switch (button) {

@@ -457,5 +457,5 @@ case 5:

command = battery_dwheel_command; break; } - tint_exec(command); + tint_exec(command, NULL, NULL, time); }
M src/battery/battery.hsrc/battery/battery.h

@@ -108,7 +108,7 @@ void battery_default_font_changed();

gboolean resize_battery(void *obj); -void battery_action(int button); +void battery_action(int button, Time time); /* operating system specific functions */ gboolean battery_os_init();
M src/button/button.csrc/button/button.c

@@ -513,7 +513,7 @@ button->backend->centered ? "center" : "left",

button->backend->text); } -void button_action(void *obj, int mouse_button, int x, int y) +void button_action(void *obj, int mouse_button, int x, int y, Time time) { Button *button = (Button *)obj; Panel *panel = (Panel *)button->area.panel;

@@ -626,18 +626,8 @@ panel_y1,

panel_x2, panel_y2, command); - pid_t pid = fork(); - if (pid < 0) { - fprintf(stderr, "Could not fork\n"); - } else if (pid == 0) { - // Child process - // Allow children to exist after parent destruction - setsid(); - // Run the command - execl("/bin/sh", "/bin/sh", "-c", full_cmd, NULL); - fprintf(stderr, "Failed to execlp %s\n", full_cmd); - exit(1); - } + tint_exec(full_cmd, NULL, NULL, time); + g_free(full_cmd); } }
M src/button/button.hsrc/button/button.h

@@ -103,7 +103,7 @@ // Returns 1 if the new size is different than the previous size.

gboolean resize_button(void *obj); // Called on mouse click event. -void button_action(void *obj, int button, int x, int y); +void button_action(void *obj, int button, int x, int y, Time time); void button_default_font_changed(); void button_default_icon_theme_changed();
M src/clock/clock.csrc/clock/clock.c

@@ -393,7 +393,7 @@ strftime(buf_tooltip, sizeof(buf_tooltip), time_tooltip_format, clock_gettime_for_tz(time_tooltip_timezone));

return strdup(buf_tooltip); } -void clock_action(int button) +void clock_action(int button, Time time) { char *command = NULL; switch (button) {

@@ -413,5 +413,5 @@ case 5:

command = clock_dwheel_command; break; } - tint_exec(command); + tint_exec(command, NULL, NULL, time); }
M src/clock/clock.hsrc/clock/clock.h

@@ -54,6 +54,6 @@ void draw_clock(void *obj, cairo_t *c);

gboolean resize_clock(void *obj); -void clock_action(int button); +void clock_action(int button, Time time); #endif
M src/config.csrc/config.c

@@ -62,8 +62,8 @@

#endif // global path -char *config_path; -char *snapshot_path; +char *config_path = NULL; +char *snapshot_path = NULL; #ifndef TINT2CONF
M src/execplugin/execplugin.csrc/execplugin/execplugin.c

@@ -557,7 +557,7 @@ execp->backend->timer = add_timeout(10, 0, execp_timer_callback, execp, &execp->backend->timer);

} } -void execp_action(void *obj, int button, int x, int y) +void execp_action(void *obj, int button, int x, int y, Time time) { Execp *execp = obj; char *command = NULL;

@@ -588,20 +588,7 @@ y,

execp->area.width, execp->area.height, command); - pid_t pid = fork(); - if (pid < 0) { - fprintf(stderr, "Could not fork\n"); - } else if (pid == 0) { - // Child process - // Allow children to exist after parent destruction - setsid(); - // Run the command - execl("/bin/sh", "/bin/sh", "-c", full_cmd, NULL); - fprintf(stderr, "Failed to execlp %s\n", full_cmd); - exit(1); - } - // Parent process - g_tree_insert(execp->backend->cmd_pids, GINT_TO_POINTER(pid), GINT_TO_POINTER(1)); + tint_exec(full_cmd, NULL, NULL, time); g_free(full_cmd); } else { execp_force_update(execp);
M src/execplugin/execplugin.hsrc/execplugin/execplugin.h

@@ -129,7 +129,7 @@ // Returns 1 if the new size is different than the previous size.

gboolean resize_execp(void *obj); // Called on mouse click event. -void execp_action(void *obj, int button, int x, int y); +void execp_action(void *obj, int button, int x, int y, Time time); void execp_cmd_completed(Execp *obj, pid_t pid);
M src/launcher/launcher.csrc/launcher/launcher.c

@@ -50,7 +50,6 @@ int launcher_brightness;

char *icon_theme_name_config; char *icon_theme_name_xsettings; int launcher_icon_theme_override; -int startup_notifications; Background *launcher_icon_bg; GList *launcher_icon_gradients;

@@ -420,60 +419,9 @@ void launcher_action(LauncherIcon *icon, XEvent *evt)

{ launcher_reload_icon((Launcher *)icon->area.parent, icon); launcher_reload_hidden_icons((Launcher *)icon->area.parent); - char *cmd = calloc(strlen(icon->cmd) + 10, 1); - sprintf(cmd, "(%s&)", icon->cmd); -#if HAVE_SN - SnLauncherContext *ctx = 0; - Time time; - if (startup_notifications) { - ctx = sn_launcher_context_new(server.sn_display, server.screen); - sn_launcher_context_set_name(ctx, icon->icon_tooltip); - sn_launcher_context_set_description(ctx, "Application launched from tint2"); - sn_launcher_context_set_binary_name(ctx, icon->cmd); - // Get a timestamp from the X event - if (evt->type == ButtonPress || evt->type == ButtonRelease) { - time = evt->xbutton.time; - } else { - fprintf(stderr, "Unknown X event: %d\n", evt->type); - free(cmd); - return; - } - sn_launcher_context_initiate(ctx, "tint2", icon->cmd, time); - } -#endif /* HAVE_SN */ - pid_t pid; - pid = fork(); - if (pid < 0) { - fprintf(stderr, "Could not fork\n"); - } else if (pid == 0) { -// Child process -#if HAVE_SN - if (startup_notifications) { - sn_launcher_context_setup_child_process(ctx); - } -#endif // HAVE_SN - // Allow children to exist after parent destruction - setsid(); - // Run the command - if (icon->cwd) - chdir(icon->cwd); - execl("/bin/sh", "/bin/sh", "-c", icon->cmd, NULL); - fprintf(stderr, "Failed to execlp %s\n", icon->cmd); -#if HAVE_SN - if (startup_notifications) { - sn_launcher_context_unref(ctx); - } -#endif // HAVE_SN - exit(1); - } else { -// Parent process -#if HAVE_SN - if (startup_notifications) { - g_tree_insert(server.pids, GINT_TO_POINTER(pid), ctx); - } -#endif // HAVE_SN - } - free(cmd); + + if (evt->type == ButtonPress || evt->type == ButtonRelease) + tint_exec(icon->cmd, icon->cwd, icon->icon_tooltip, evt->xbutton.time); } // Populates the list_icons list from the list_apps list
M src/launcher/launcher.hsrc/launcher/launcher.h

@@ -49,7 +49,6 @@ extern int launcher_brightness;

extern char *icon_theme_name_xsettings; // theme name extern char *icon_theme_name_config; extern int launcher_icon_theme_override; -extern int startup_notifications; extern Background *launcher_icon_bg; extern GList *launcher_icon_gradients;
M src/panel.csrc/panel.c

@@ -57,6 +57,7 @@ gboolean task_dragged;

char *panel_window_name = NULL; gboolean debug_geometry; gboolean debug_gradients; +gboolean startup_notifications; gboolean panel_autohide; int panel_autohide_show_timeout;
M src/panel.hsrc/panel.h

@@ -90,6 +90,7 @@ extern Imlib_Image default_icon;

#define DEFAULT_FONT "sans 10" extern char *default_font; extern XSettingsClient *xsettings_client; +extern gboolean startup_notifications; extern gboolean debug_geometry; extern gboolean debug_fps; extern gboolean debug_frames;
M src/tint.csrc/tint.c

@@ -968,7 +968,7 @@ break;

} if (click_clock(panel, e->xbutton.x, e->xbutton.y)) { - clock_action(e->xbutton.button); + clock_action(e->xbutton.button, e->xbutton.time); if (panel_layer == BOTTOM_LAYER) XLowerWindow(server.display, panel->main_win); task_drag = 0;

@@ -977,7 +977,7 @@ }

#ifdef ENABLE_BATTERY if (click_battery(panel, e->xbutton.x, e->xbutton.y)) { - battery_action(e->xbutton.button); + battery_action(e->xbutton.button, e->xbutton.time); if (panel_layer == BOTTOM_LAYER) XLowerWindow(server.display, panel->main_win); task_drag = 0;

@@ -987,7 +987,7 @@ #endif

Execp *execp = click_execp(panel, e->xbutton.x, e->xbutton.y); if (execp) { - execp_action(execp, e->xbutton.button, e->xbutton.x - execp->area.posx, e->xbutton.y - execp->area.posy); + execp_action(execp, e->xbutton.button, e->xbutton.x - execp->area.posx, e->xbutton.y - execp->area.posy, e->xbutton.time); if (panel_layer == BOTTOM_LAYER) XLowerWindow(server.display, panel->main_win); task_drag = 0;

@@ -996,7 +996,7 @@ }

Button *button = click_button(panel, e->xbutton.x, e->xbutton.y); if (button) { - button_action(button, e->xbutton.button, e->xbutton.x - button->area.posx, e->xbutton.y - button->area.posy); + button_action(button, e->xbutton.button, e->xbutton.x - button->area.posx, e->xbutton.y - button->area.posy, e->xbutton.time); if (panel_layer == BOTTOM_LAYER) XLowerWindow(server.display, panel->main_win); task_drag = 0;

@@ -2131,7 +2131,7 @@ }

strcat(cmd, "\""); strcat(cmd, "&)"); fprintf(stderr, "DnD %s:%d: Running command: %s\n", __FILE__, __LINE__, cmd); - tint_exec(cmd); + tint_exec(cmd, NULL, NULL, e.xselection.time); free(cmd); // Reply OK.
M src/tint2conf/main.csrc/tint2conf/main.c

@@ -340,6 +340,10 @@ argc--, argv++;

if (argc > 0) { load_specific_themes(argv, argc); g_timeout_add(SNAPSHOT_TICK, edit_theme, NULL); + } else if (getenv("TINT2_CONFIG")) { + char *themes[2] = {getenv("TINT2_CONFIG"), NULL}; + load_specific_themes(themes, 1); + g_timeout_add(SNAPSHOT_TICK, edit_theme, NULL); } gtk_widget_show_all(g_window);
M src/util/common.csrc/util/common.c

@@ -44,6 +44,8 @@ #ifdef HAVE_RSVG

#include <librsvg/rsvg.h> #endif +#include "../panel.h" + void copy_file(const char *path_src, const char *path_dest) { if (g_str_equal(path_src, path_dest))

@@ -99,18 +101,70 @@ g_strstrip(*value);

return TRUE; } -void tint_exec(const char *command) +extern char *config_path; + +void tint_exec(const char *command, const char *dir, const char *tooltip, Time time) { - if (command) { - if (fork() == 0) { - // change for the fork the signal mask - // sigset_t sigset; - // sigprocmask(SIG_SETMASK, &sigset, 0); - // sigprocmask(SIG_UNBLOCK, &sigset, 0); - execl("/bin/sh", "/bin/sh", "-c", command, NULL); - _exit(0); + if (!command || strlen(command) == 0) + return; + + command = g_strdup_printf("export TINT2_CONFIG=%s;" + "%s", + config_path, + command); + if (!command) + return; + + if (!tooltip) + tooltip = command; + +#if HAVE_SN && !defined TINT2CONF + SnLauncherContext *ctx = 0; + if (startup_notifications && time) { + ctx = sn_launcher_context_new(server.sn_display, server.screen); + sn_launcher_context_set_name(ctx, tooltip); + sn_launcher_context_set_description(ctx, "Application launched from tint2"); + sn_launcher_context_set_binary_name(ctx, command); + sn_launcher_context_initiate(ctx, "tint2", command, time); + } +#endif /* HAVE_SN */ + pid_t pid; + pid = fork(); + if (pid < 0) { + fprintf(stderr, "Could not fork\n"); + } else if (pid == 0) { +// Child process +#if HAVE_SN && !defined TINT2CONF + if (startup_notifications && time) { + sn_launcher_context_setup_child_process(ctx); } +#endif // HAVE_SN + // Allow children to exist after parent destruction + setsid(); + // Run the command + if (dir) + chdir(dir); + execl("/bin/sh", "/bin/sh", "-c", command, NULL); + fprintf(stderr, "Failed to execlp %s\n", command); +#if HAVE_SN && !defined TINT2CONF + if (startup_notifications && time) { + sn_launcher_context_unref(ctx); + } +#endif // HAVE_SN + _exit(1); + } else { +// Parent process +#if HAVE_SN && !defined TINT2CONF + if (startup_notifications && time) { + g_tree_insert(server.pids, GINT_TO_POINTER(pid), ctx); + } +#endif // HAVE_SN } +} + +void tint_exec_no_sn(const char *command) +{ + tint_exec(command, NULL, NULL, 0); } char *expand_tilde(const char *s)
M src/util/common.hsrc/util/common.h

@@ -54,7 +54,8 @@ void extract_values(const char *value, char **value1, char **value2, char **value3);

void extract_values_4(const char *value, char **value1, char **value2, char **value3, char **value4); // Executes a command in a shell. -void tint_exec(const char *command); +void tint_exec(const char *command, const char *dir, const char *tooltip, Time time); +void tint_exec_no_sn(const char *command); // Returns a copy of s in which "~" is expanded to the path to the user's home directory. // The caller takes ownership of the string.