=== Automatically starting applications on i3 startup
-By using the +exec+ keyword outside a keybinding, you can configure which
-commands will be performed by i3 on initial startup (not when restarting i3
-in-place however). These commands will be run in order.
+By using the +exec+ keyword outside a keybinding, you can configure
+which commands will be performed by i3 on initial startup. +exec+
+commands will not run when restarting i3, if you need a command to run
+also when restarting i3 you should use the +exec_always+
+keyword. These commands will be run in order.
*Syntax*:
-------------
+-------------------
exec command
-------------
+exec_always command
+-------------------
*Examples*:
--------------------------------
exec i3status | dzen2 -dock
+exec_always ~/my_script.sh
--------------------------------
[[workspace_screen]]
};
/**
- * Holds a command specified by an exec-line in the config (see src/config.c)
+ * Holds a command specified by either an:
+ * - exec-line
+ * - exec_always-line
+ * in the config (see src/config.c)
*
*/
struct Autostart {
/** Command, like in command mode */
char *command;
TAILQ_ENTRY(Autostart) autostarts;
+ TAILQ_ENTRY(Autostart) autostarts_always;
};
/**
extern int xkb_current_group;
extern TAILQ_HEAD(bindings_head, Binding) *bindings;
extern TAILQ_HEAD(autostarts_head, Autostart) autostarts;
+extern TAILQ_HEAD(autostarts_always_head, Autostart) autostarts_always;
extern TAILQ_HEAD(ws_assignments_head, Workspace_Assignment) ws_assignments;
extern TAILQ_HEAD(assignments_head, Assignment) assignments;
extern SLIST_HEAD(stack_wins_head, Stack_Window) stack_wins;
cols { /* yylval.number = STACK_LIMIT_COLS; */return TOKSTACKLIMIT; }
rows { /* yylval.number = STACK_LIMIT_ROWS; */return TOKSTACKLIMIT; }
exec { WS_STRING; return TOKEXEC; }
+exec_always { WS_STRING; return TOKEXEC_ALWAYS; }
client.background { BEGIN(COLOR_COND); yylval.single_color = &config.client.background; return TOKSINGLECOLOR; }
client.focused { BEGIN(COLOR_COND); yylval.color = &config.client.focused; return TOKCOLOR; }
client.focused_inactive { BEGIN(COLOR_COND); yylval.color = &config.client.focused_inactive; return TOKCOLOR; }
%token TOKIPCSOCKET "ipc_socket"
%token TOKRESTARTSTATE "restart_state"
%token TOKEXEC "exec"
+%token TOKEXEC_ALWAYS "exec_always"
%token <single_color> TOKSINGLECOLOR
%token <color> TOKCOLOR
%token TOKARROW "→"
| ipcsocket
| restart_state
| exec
+ | exec_always
| single_color
| color
| terminal
}
;
+exec_always:
+ TOKEXEC_ALWAYS STR
+ {
+ struct Autostart *new = smalloc(sizeof(struct Autostart));
+ new->command = $2;
+ TAILQ_INSERT_TAIL(&autostarts_always, new, autostarts_always);
+ }
+ ;
+
terminal:
TOKTERMINAL STR
{
/* The list of exec-lines */
struct autostarts_head autostarts = TAILQ_HEAD_INITIALIZER(autostarts);
+/* The list of exec_always lines */
+struct autostarts_always_head autostarts_always = TAILQ_HEAD_INITIALIZER(autostarts_always);
+
/* The list of assignments */
struct assignments_head assignments = TAILQ_HEAD_INITIALIZER(assignments);
}
}
+ /* Autostarting exec_always-lines */
+ struct Autostart *exec_always;
+ TAILQ_FOREACH(exec_always, &autostarts_always, autostarts_always) {
+ LOG("auto-starting (always!) %s\n", exec_always->command);
+ start_application(exec_always->command);
+ }
+
ev_loop(main_loop, 0);
}