patch to allow exec_always in configure file

fixed indentation, updated docs
This commit is contained in:
Claudio Marforio 2011-07-12 12:24:01 +02:00 committed by Michael Stapelberg
parent 5555c0fd3b
commit cc24a96e96
6 changed files with 37 additions and 6 deletions

View File

@ -469,18 +469,22 @@ use it, it has to be a UTF-8 encoded arrow, not `->` or something like that.
=== Automatically starting applications on i3 startup === Automatically starting applications on i3 startup
By using the +exec+ keyword outside a keybinding, you can configure which By using the +exec+ keyword outside a keybinding, you can configure
commands will be performed by i3 on initial startup (not when restarting i3 which commands will be performed by i3 on initial startup. +exec+
in-place however). These commands will be run in order. 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*: *Syntax*:
------------ -------------------
exec command exec command
------------ exec_always command
-------------------
*Examples*: *Examples*:
-------------------------------- --------------------------------
exec i3status | dzen2 -dock exec i3status | dzen2 -dock
exec_always ~/my_script.sh
-------------------------------- --------------------------------
[[workspace_screen]] [[workspace_screen]]

View File

@ -174,13 +174,17 @@ struct Binding {
}; };
/** /**
* 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 { struct Autostart {
/** Command, like in command mode */ /** Command, like in command mode */
char *command; char *command;
TAILQ_ENTRY(Autostart) autostarts; TAILQ_ENTRY(Autostart) autostarts;
TAILQ_ENTRY(Autostart) autostarts_always;
}; };
/** /**

View File

@ -26,6 +26,7 @@ extern Display *xlibdpy, *xkbdpy;
extern int xkb_current_group; extern int xkb_current_group;
extern TAILQ_HEAD(bindings_head, Binding) *bindings; extern TAILQ_HEAD(bindings_head, Binding) *bindings;
extern TAILQ_HEAD(autostarts_head, Autostart) autostarts; 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(ws_assignments_head, Workspace_Assignment) ws_assignments;
extern TAILQ_HEAD(assignments_head, Assignment) assignments; extern TAILQ_HEAD(assignments_head, Assignment) assignments;
extern SLIST_HEAD(stack_wins_head, Stack_Window) stack_wins; extern SLIST_HEAD(stack_wins_head, Stack_Window) stack_wins;

View File

@ -147,6 +147,7 @@ stack-limit { return TOKSTACKLIMIT; }
cols { /* yylval.number = STACK_LIMIT_COLS; */return TOKSTACKLIMIT; } cols { /* yylval.number = STACK_LIMIT_COLS; */return TOKSTACKLIMIT; }
rows { /* yylval.number = STACK_LIMIT_ROWS; */return TOKSTACKLIMIT; } rows { /* yylval.number = STACK_LIMIT_ROWS; */return TOKSTACKLIMIT; }
exec { WS_STRING; return TOKEXEC; } 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.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 { BEGIN(COLOR_COND); yylval.color = &config.client.focused; return TOKCOLOR; }
client.focused_inactive { BEGIN(COLOR_COND); yylval.color = &config.client.focused_inactive; return TOKCOLOR; } client.focused_inactive { BEGIN(COLOR_COND); yylval.color = &config.client.focused_inactive; return TOKCOLOR; }

View File

@ -518,6 +518,7 @@ void parse_file(const char *f) {
%token TOKIPCSOCKET "ipc_socket" %token TOKIPCSOCKET "ipc_socket"
%token TOKRESTARTSTATE "restart_state" %token TOKRESTARTSTATE "restart_state"
%token TOKEXEC "exec" %token TOKEXEC "exec"
%token TOKEXEC_ALWAYS "exec_always"
%token <single_color> TOKSINGLECOLOR %token <single_color> TOKSINGLECOLOR
%token <color> TOKCOLOR %token <color> TOKCOLOR
%token TOKARROW "→" %token TOKARROW "→"
@ -590,6 +591,7 @@ line:
| ipcsocket | ipcsocket
| restart_state | restart_state
| exec | exec
| exec_always
| single_color | single_color
| color | color
| terminal | terminal
@ -1036,6 +1038,15 @@ exec:
} }
; ;
exec_always:
TOKEXEC_ALWAYS STR
{
struct Autostart *new = smalloc(sizeof(struct Autostart));
new->command = $2;
TAILQ_INSERT_TAIL(&autostarts_always, new, autostarts_always);
}
;
terminal: terminal:
TOKTERMINAL STR TOKTERMINAL STR
{ {

View File

@ -32,6 +32,9 @@ struct bindings_head *bindings;
/* The list of exec-lines */ /* The list of exec-lines */
struct autostarts_head autostarts = TAILQ_HEAD_INITIALIZER(autostarts); 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 */ /* The list of assignments */
struct assignments_head assignments = TAILQ_HEAD_INITIALIZER(assignments); struct assignments_head assignments = TAILQ_HEAD_INITIALIZER(assignments);
@ -465,5 +468,12 @@ int main(int argc, char *argv[]) {
} }
} }
/* 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); ev_loop(main_loop, 0);
} }