diff --git a/include/data.h b/include/data.h index a54798ba..e511a7fb 100644 --- a/include/data.h +++ b/include/data.h @@ -48,6 +48,7 @@ typedef struct Font i3Font; typedef struct Container Container; typedef struct Client Client; typedef struct Binding Binding; +typedef struct Autostart Autostart; typedef struct Workspace Workspace; typedef struct Rect Rect; typedef struct Screen i3Screen; @@ -191,6 +192,16 @@ struct Binding { TAILQ_ENTRY(Binding) bindings; }; +/* + * Holds a command specified by an exec-line in the config (see src/config.c) + * + */ +struct Autostart { + /* Command, like in command mode */ + char *command; + TAILQ_ENTRY(Autostart) autostarts; +}; + /* * Data structure for cached font information: * - font id in X11 (load it once) diff --git a/include/i3.h b/include/i3.h index 02df9996..1c9e1b35 100644 --- a/include/i3.h +++ b/include/i3.h @@ -25,6 +25,7 @@ extern char **start_argv; extern Display *xkbdpy; extern TAILQ_HEAD(bindings_head, Binding) bindings; +extern TAILQ_HEAD(autostarts_head, Autostart) autostarts; extern SLIST_HEAD(stack_wins_head, Stack_Window) stack_wins; extern xcb_event_handlers_t evenths; extern int num_screens; diff --git a/src/config.c b/src/config.c index 73d39021..ca84282a 100644 --- a/src/config.c +++ b/src/config.c @@ -85,6 +85,15 @@ void load_configuration(const char *override_configpath) { OPTION_STRING(terminal); OPTION_STRING(font); + /* exec-lines (autostart) */ + if (strcasecmp(key, "exec") == 0) { + Autostart *new = smalloc(sizeof(Autostart)); + new->command = sstrdup(value); + TAILQ_INSERT_TAIL(&autostarts, new, autostarts); + continue; + } + + /* key bindings */ if (strcasecmp(key, "bind") == 0) { #define CHECK_MODIFIER(name) \ if (strncasecmp(walk, #name, strlen(#name)) == 0) { \ diff --git a/src/mainx.c b/src/mainx.c index e89eaab0..da79ee3a 100644 --- a/src/mainx.c +++ b/src/mainx.c @@ -52,6 +52,9 @@ Display *xkbdpy; /* The list of key bindings */ struct bindings_head bindings = TAILQ_HEAD_INITIALIZER(bindings); +/* The list of exec-lines */ +struct autostarts_head autostarts = TAILQ_HEAD_INITIALIZER(autostarts); + /* This is a list of Stack_Windows, global, for easier/faster access on expose events */ struct stack_wins_head stack_wins = SLIST_HEAD_INITIALIZER(stack_wins); @@ -527,6 +530,13 @@ int main(int argc, char *argv[], char *env[]) { } } + /* Autostarting exec-lines */ + Autostart *exec; + TAILQ_FOREACH(exec, &autostarts, autostarts) { + LOG("auto-starting %s\n", exec->command); + start_application(exec->command); + } + /* check for Xinerama */ LOG("Checking for Xinerama...\n"); initialize_xinerama(conn);