allow parameters to dmenu and browser calls

This commit is contained in:
Sascha Kruse 2012-12-19 16:38:14 +01:00
parent 42e49a7b34
commit 02bd587935
4 changed files with 31 additions and 4 deletions

12
dunst.c
View File

@ -72,6 +72,8 @@ static int font_h;
static bool print_notifications = false;
static dimension_t window_dim;
static bool pause_display = false;
static char **dmenu_cmd;
static char **browser_cmd;
static r_line_cache line_cache;
@ -167,6 +169,9 @@ void context_menu(void) {
iter = iter->next;
}
if (!dmenu_input)
return;
int child_io[2];
int parent_io[2];
pipe(child_io);
@ -180,7 +185,7 @@ void context_menu(void) {
dup(child_io[0]);
close(1);
dup(parent_io[1]);
execlp(dmenu, dmenu, (char *) NULL);
execvp(dmenu_cmd[0], dmenu_cmd);
} else {
close(child_io[0]);
close(parent_io[1]);
@ -199,7 +204,7 @@ void context_menu(void) {
int browser_pid = fork();
if (browser_pid == 0) {
execlp(browser, browser, (char *) NULL);
execvp(browser_cmd[0], browser_cmd);
} else {
return;
}
@ -1562,7 +1567,10 @@ void load_options(char *cmdline_config_path)
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_cmd = string_to_argv(browser);
lowbgcolor =
option_get_string("urgency_low", "background", "-lb", lowbgcolor,

View File

@ -95,10 +95,10 @@
startup_notification = false
# dmenu path
dmenu = "/usr/bin/dmenu"
dmenu = /usr/bin/dmenu -p dunst:
# browser for opening urls in context menu
browser = /usr/bin/firefox
browser = /usr/bin/firefox -new-tab
[shortcuts]

17
utils.c
View File

@ -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 len = 0;

View File

@ -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_to_argv(const char *str);
/* exit with an error message */
void die(char *msg, int exit_value);