From e4e8ab2880e9b217041c60d8a32ce75684f43835 Mon Sep 17 00:00:00 2001 From: Sean Pringle Date: Thu, 8 Jan 2015 07:33:21 +1000 Subject: [PATCH] support "launch " in .xoatrc --- config.c | 13 +++++++++++++ setup.c | 7 +++++++ xoat.c | 3 +++ xoatrc | 6 +++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index dd5ea34..0697efb 100644 --- a/config.c +++ b/config.c @@ -89,6 +89,9 @@ configure() settings.binding_count = sizeof(keys) / sizeof(Binding); settings.bindings = calloc(settings.binding_count, sizeof(Binding)); + settings.launchcmd_count = 0; + settings.launchcmds = calloc(1, sizeof(char*)); + for (i = 0; i < settings.binding_count; i++) memmove(&settings.bindings[i], &keys[i], sizeof(Binding)); @@ -435,6 +438,16 @@ configure() settings.bindings[i].num = num; } } + else + if (regex_match("^launch[[:space:]]+(.+)$", tmp)) + { + rtrim(regex_matches[1]); + + settings.launchcmd_count++; + settings.launchcmds = realloc(settings.launchcmds, sizeof(char*) * settings.launchcmd_count); + settings.launchcmds[settings.launchcmd_count-1] = strdup(regex_matches[1]); + fprintf(stderr, "launching [%s]\n", regex_matches[1]); + } } fclose(file); diff --git a/setup.c b/setup.c index dc120cc..4e635f1 100644 --- a/setup.c +++ b/setup.c @@ -216,4 +216,11 @@ void setup() client_place_spot(c, c->spot, c->monitor, 0); if (!current) client_activate(c); } + + // auto launch + if (settings.launchcmd_count) + { + for (i = 0; i < settings.launchcmd_count; i++) + exec_cmd(settings.launchcmds[i]); + } } diff --git a/xoat.c b/xoat.c index 2993b8f..e797823 100644 --- a/xoat.c +++ b/xoat.c @@ -116,6 +116,9 @@ typedef struct _Settings { unsigned int binding_count; Binding *bindings; + + unsigned int launchcmd_count; + char **launchcmds; } Settings; #define have_layout(i) (settings.layout_count > (i)) diff --git a/xoatrc b/xoatrc index 4429670..8fdb1b5 100644 --- a/xoatrc +++ b/xoatrc @@ -132,4 +132,8 @@ bind F4 action_find_or_start sublime-text # Also possible to bind by keysym hex value # Eg, XF86XK_MonBrightnessUp = 0x1008FF02 -# bind 0x1008FF02 action_command \ No newline at end of file +# bind 0x1008FF02 action_command + +# Launch apps (or any command) at startup +# launch xterm +# launch xsetroot -cursor_name left_ptr \ No newline at end of file