Use shell to execute notifyext (-e)
Fix `spt -e 'mpv music.ogg' -n notify-send`, use execvp to allow easier reuse of the cmt that appeared later. Fix #15
This commit is contained in:
parent
c2b5ba6b3c
commit
bf82caf6e0
12
spt.c
12
spt.c
|
@ -29,7 +29,7 @@ volatile static sig_atomic_t display, suspend;
|
||||||
|
|
||||||
/* function declarations */
|
/* function declarations */
|
||||||
static void die(const char *errstr, ...);
|
static void die(const char *errstr, ...);
|
||||||
static void spawn(char *cmd, char *cmt);
|
static void spawn(char *argv[]);
|
||||||
static void notify_send(char *cmt);
|
static void notify_send(char *cmt);
|
||||||
static void display_state(int remaining, int suspend);
|
static void display_state(int remaining, int suspend);
|
||||||
static void toggle_display(int sigint);
|
static void toggle_display(int sigint);
|
||||||
|
@ -49,12 +49,12 @@ die(const char *errstr, ...)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawn(char *cmd, char *cmt)
|
spawn(char *argv[])
|
||||||
{
|
{
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
setsid();
|
setsid();
|
||||||
execlp(cmd, cmd, "spt", cmt, NULL);
|
execvp(argv[0], argv);
|
||||||
die("spt: execlp %s\n", cmd);
|
die("spt: execvp %s\n", argv[0]);
|
||||||
perror(" failed");
|
perror(" failed");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ void
|
||||||
notify_send(char *cmt)
|
notify_send(char *cmt)
|
||||||
{
|
{
|
||||||
if (strcmp(notifycmd, ""))
|
if (strcmp(notifycmd, ""))
|
||||||
spawn(notifycmd, cmt);
|
spawn((char *[]) { notifycmd, "spt", cmt, NULL });
|
||||||
#ifdef NOTIFY
|
#ifdef NOTIFY
|
||||||
else {
|
else {
|
||||||
notify_init("spt");
|
notify_init("spt");
|
||||||
|
@ -77,7 +77,7 @@ notify_send(char *cmt)
|
||||||
#endif /* NOTIFY */
|
#endif /* NOTIFY */
|
||||||
|
|
||||||
if (strcmp(notifyext, "")) /* extra commands to use */
|
if (strcmp(notifyext, "")) /* extra commands to use */
|
||||||
spawn(notifyext, NULL);
|
spawn((char *[]) { "/bin/sh", "-c", notifyext, NULL });
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in New Issue
Block a user