Do not pollute command line of executed processes
This commit is contained in:
@@ -579,17 +579,15 @@ void execp_action(void *obj, int button, int x, int y, Time time)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (command) {
|
if (command) {
|
||||||
char *full_cmd = g_strdup_printf("export EXECP_X=%d;"
|
setenvd("EXECP_X", x);
|
||||||
"export EXECP_Y=%d;"
|
setenvd("EXECP_Y", y);
|
||||||
"export EXECP_W=%d;"
|
setenvd("EXECP_W", execp->area.width);
|
||||||
"export EXECP_H=%d; %s",
|
setenvd("EXECP_H", execp->area.height);
|
||||||
x,
|
pid_t pid = tint_exec(command, NULL, NULL, time, obj, x, y);
|
||||||
y,
|
unsetenv("EXECP_X");
|
||||||
execp->area.width,
|
unsetenv("EXECP_Y");
|
||||||
execp->area.height,
|
unsetenv("EXECP_W");
|
||||||
command);
|
unsetenv("EXECP_H");
|
||||||
pid_t pid = tint_exec(full_cmd, NULL, NULL, time, obj, x, y);
|
|
||||||
g_free(full_cmd);
|
|
||||||
if (pid > 0)
|
if (pid > 0)
|
||||||
g_tree_insert(execp->backend->cmd_pids, GINT_TO_POINTER(pid), GINT_TO_POINTER(1));
|
g_tree_insert(execp->backend->cmd_pids, GINT_TO_POINTER(pid), GINT_TO_POINTER(1));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -103,6 +103,13 @@ gboolean parse_line(const char *line, char **key, char **value)
|
|||||||
|
|
||||||
extern char *config_path;
|
extern char *config_path;
|
||||||
|
|
||||||
|
int setenvd(const char *name, const int value)
|
||||||
|
{
|
||||||
|
char buf[256];
|
||||||
|
sprintf(buf, "%d", value);
|
||||||
|
return setenv(name, buf, 1);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef TINT2CONF
|
#ifndef TINT2CONF
|
||||||
pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time time, Area *area, int x, int y)
|
pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time time, Area *area, int x, int y)
|
||||||
{
|
{
|
||||||
@@ -172,43 +179,23 @@ pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time
|
|||||||
panel_y2 = panel->posy + panel->area.height;
|
panel_y2 = panel->posy + panel->area.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
command = g_strdup_printf("export TINT2_CONFIG=%s;"
|
setenv("TINT2_CONFIG", config_path, 1);
|
||||||
"export TINT2_BUTTON_X=%d;"
|
setenvd("TINT2_BUTTON_X", x);
|
||||||
"export TINT2_BUTTON_Y=%d;"
|
setenvd("TINT2_BUTTON_Y", y);
|
||||||
"export TINT2_BUTTON_W=%d;"
|
setenvd("TINT2_BUTTON_W", area->width);
|
||||||
"export TINT2_BUTTON_H=%d;"
|
setenvd("TINT2_BUTTON_H", area->height);
|
||||||
"export TINT2_BUTTON_ALIGNED_X=%d;"
|
setenvd("TINT2_BUTTON_ALIGNED_X", aligned_x);
|
||||||
"export TINT2_BUTTON_ALIGNED_Y=%d;"
|
setenvd("TINT2_BUTTON_ALIGNED_Y", aligned_y);
|
||||||
"export TINT2_BUTTON_ALIGNED_X1=%d;"
|
setenvd("TINT2_BUTTON_ALIGNED_X1", aligned_x1);
|
||||||
"export TINT2_BUTTON_ALIGNED_Y1=%d;"
|
setenvd("TINT2_BUTTON_ALIGNED_Y1", aligned_y1);
|
||||||
"export TINT2_BUTTON_ALIGNED_X2=%d;"
|
setenvd("TINT2_BUTTON_ALIGNED_X2", aligned_x2);
|
||||||
"export TINT2_BUTTON_ALIGNED_Y2=%d;"
|
setenvd("TINT2_BUTTON_ALIGNED_Y2", aligned_y2);
|
||||||
"export TINT2_BUTTON_PANEL_X1=%d;"
|
setenvd("TINT2_BUTTON_PANEL_X1", panel_x1);
|
||||||
"export TINT2_BUTTON_PANEL_Y1=%d;"
|
setenvd("TINT2_BUTTON_PANEL_Y1", panel_y1);
|
||||||
"export TINT2_BUTTON_PANEL_X2=%d;"
|
setenvd("TINT2_BUTTON_PANEL_X2", panel_x2);
|
||||||
"export TINT2_BUTTON_PANEL_Y2=%d;"
|
setenvd("TINT2_BUTTON_PANEL_Y2", panel_y2);
|
||||||
"%s",
|
|
||||||
config_path,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
area->width,
|
|
||||||
area->height,
|
|
||||||
aligned_x,
|
|
||||||
aligned_y,
|
|
||||||
aligned_x1,
|
|
||||||
aligned_y1,
|
|
||||||
aligned_x2,
|
|
||||||
aligned_y2,
|
|
||||||
panel_x1,
|
|
||||||
panel_y1,
|
|
||||||
panel_x2,
|
|
||||||
panel_y2,
|
|
||||||
command);
|
|
||||||
} else {
|
} else {
|
||||||
command = g_strdup_printf("export TINT2_CONFIG=%s;"
|
setenv("TINT2_CONFIG", config_path, 1);
|
||||||
"%s",
|
|
||||||
config_path,
|
|
||||||
command);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!command)
|
if (!command)
|
||||||
@@ -259,6 +246,23 @@ pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time
|
|||||||
}
|
}
|
||||||
#endif // HAVE_SN
|
#endif // HAVE_SN
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsetenv("TINT2_CONFIG");
|
||||||
|
unsetenv("TINT2_BUTTON_X");
|
||||||
|
unsetenv("TINT2_BUTTON_Y");
|
||||||
|
unsetenv("TINT2_BUTTON_W");
|
||||||
|
unsetenv("TINT2_BUTTON_H");
|
||||||
|
unsetenv("TINT2_BUTTON_ALIGNED_X");
|
||||||
|
unsetenv("TINT2_BUTTON_ALIGNED_Y");
|
||||||
|
unsetenv("TINT2_BUTTON_ALIGNED_X1");
|
||||||
|
unsetenv("TINT2_BUTTON_ALIGNED_Y1");
|
||||||
|
unsetenv("TINT2_BUTTON_ALIGNED_X2");
|
||||||
|
unsetenv("TINT2_BUTTON_ALIGNED_Y2");
|
||||||
|
unsetenv("TINT2_BUTTON_PANEL_X1");
|
||||||
|
unsetenv("TINT2_BUTTON_PANEL_Y1");
|
||||||
|
unsetenv("TINT2_BUTTON_PANEL_X2");
|
||||||
|
unsetenv("TINT2_BUTTON_PANEL_Y2");
|
||||||
|
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ void extract_values_4(const char *value, char **value1, char **value2, char **va
|
|||||||
// Executes a command in a shell.
|
// Executes a command in a shell.
|
||||||
pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time time, Area *area, int x, int y);
|
pid_t tint_exec(const char *command, const char *dir, const char *tooltip, Time time, Area *area, int x, int y);
|
||||||
void tint_exec_no_sn(const char *command);
|
void tint_exec_no_sn(const char *command);
|
||||||
|
int setenvd(const char *name, const int value);
|
||||||
|
|
||||||
// Returns a copy of s in which "~" is expanded to the path to the user's home directory.
|
// 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.
|
// The caller takes ownership of the string.
|
||||||
|
|||||||
Reference in New Issue
Block a user