allow parameters to dmenu and browser calls
This commit is contained in:
parent
42e49a7b34
commit
02bd587935
12
dunst.c
12
dunst.c
@ -72,6 +72,8 @@ static int font_h;
|
|||||||
static bool print_notifications = false;
|
static bool print_notifications = false;
|
||||||
static dimension_t window_dim;
|
static dimension_t window_dim;
|
||||||
static bool pause_display = false;
|
static bool pause_display = false;
|
||||||
|
static char **dmenu_cmd;
|
||||||
|
static char **browser_cmd;
|
||||||
|
|
||||||
static r_line_cache line_cache;
|
static r_line_cache line_cache;
|
||||||
|
|
||||||
@ -167,6 +169,9 @@ void context_menu(void) {
|
|||||||
iter = iter->next;
|
iter = iter->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!dmenu_input)
|
||||||
|
return;
|
||||||
|
|
||||||
int child_io[2];
|
int child_io[2];
|
||||||
int parent_io[2];
|
int parent_io[2];
|
||||||
pipe(child_io);
|
pipe(child_io);
|
||||||
@ -180,7 +185,7 @@ void context_menu(void) {
|
|||||||
dup(child_io[0]);
|
dup(child_io[0]);
|
||||||
close(1);
|
close(1);
|
||||||
dup(parent_io[1]);
|
dup(parent_io[1]);
|
||||||
execlp(dmenu, dmenu, (char *) NULL);
|
execvp(dmenu_cmd[0], dmenu_cmd);
|
||||||
} else {
|
} else {
|
||||||
close(child_io[0]);
|
close(child_io[0]);
|
||||||
close(parent_io[1]);
|
close(parent_io[1]);
|
||||||
@ -199,7 +204,7 @@ void context_menu(void) {
|
|||||||
int browser_pid = fork();
|
int browser_pid = fork();
|
||||||
|
|
||||||
if (browser_pid == 0) {
|
if (browser_pid == 0) {
|
||||||
execlp(browser, browser, (char *) NULL);
|
execvp(browser_cmd[0], browser_cmd);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1562,7 +1567,10 @@ void load_options(char *cmdline_config_path)
|
|||||||
|
|
||||||
|
|
||||||
dmenu = option_get_string("global", "dmenu", "-dmenu", dmenu, "path to dmenu");
|
dmenu = option_get_string("global", "dmenu", "-dmenu", dmenu, "path to dmenu");
|
||||||
|
dmenu_cmd = string_to_argv(dmenu);
|
||||||
|
|
||||||
browser = option_get_string("global", "browser", "-browser", browser, "path to browser");
|
browser = option_get_string("global", "browser", "-browser", browser, "path to browser");
|
||||||
|
browser_cmd = string_to_argv(browser);
|
||||||
|
|
||||||
lowbgcolor =
|
lowbgcolor =
|
||||||
option_get_string("urgency_low", "background", "-lb", lowbgcolor,
|
option_get_string("urgency_low", "background", "-lb", lowbgcolor,
|
||||||
|
4
dunstrc
4
dunstrc
@ -95,10 +95,10 @@
|
|||||||
startup_notification = false
|
startup_notification = false
|
||||||
|
|
||||||
# dmenu path
|
# dmenu path
|
||||||
dmenu = "/usr/bin/dmenu"
|
dmenu = /usr/bin/dmenu -p dunst:
|
||||||
|
|
||||||
# browser for opening urls in context menu
|
# browser for opening urls in context menu
|
||||||
browser = /usr/bin/firefox
|
browser = /usr/bin/firefox -new-tab
|
||||||
|
|
||||||
|
|
||||||
[shortcuts]
|
[shortcuts]
|
||||||
|
17
utils.c
17
utils.c
@ -64,6 +64,23 @@ char *string_append(char *a, const char *b, const char *sep)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char **string_to_argv(const char *str)
|
||||||
|
{
|
||||||
|
char **argv = NULL;
|
||||||
|
char *p = strtok (str, " ");
|
||||||
|
int n_spaces = 0, i;
|
||||||
|
|
||||||
|
while (p) {
|
||||||
|
argv = realloc (argv, sizeof (char*) * ++n_spaces);
|
||||||
|
argv[n_spaces-1] = p;
|
||||||
|
p = strtok (NULL, " ");
|
||||||
|
}
|
||||||
|
argv = realloc (argv, sizeof (char*) * (n_spaces+1));
|
||||||
|
argv[n_spaces] = NULL;
|
||||||
|
|
||||||
|
return argv;
|
||||||
|
}
|
||||||
|
|
||||||
int digit_count(int i)
|
int digit_count(int i)
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
2
utils.h
2
utils.h
@ -10,6 +10,8 @@ char *string_replace(const char *needle, const char *replacement,
|
|||||||
|
|
||||||
char *string_append(char *a, const char *b, const char *sep);
|
char *string_append(char *a, const char *b, const char *sep);
|
||||||
|
|
||||||
|
char **string_to_argv(const char *str);
|
||||||
|
|
||||||
/* exit with an error message */
|
/* exit with an error message */
|
||||||
void die(char *msg, int exit_value);
|
void die(char *msg, int exit_value);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user