Skip to content
Bakkeby edited this page Apr 18, 2024 · 4 revisions
Function Expected argument Default keybindings
spawn list of strings (execvp command) Super+d, Super+enter

The spawn function is used to start new processes.

This is used:

  • directly via keybindings to open specific programs
  • internally when spawning scratchpads
  • internally when using the riospawn feature

The Super+d keybinding launches dmenu via the spawn function.

The Super+enter keybinding opens a terminal window via the spawn function.

The argument is a list of strings that make up an execvp command, which basically just means that the command and command line arguments are separate strings.

Synopsis:

/* Spawn command:               command, argument, argument, ..., NULL */
static const char *mycmd[]  = { command, argument, argument, ..., NULL };

Example implementations:

static const char *spcmd[] = {"w", "st", "-n", "spterm (w)", "-g", "120x34", NULL };
static const char *statusclickcmd[] = { "~/bin/statusbar/statusclick.sh", NULL };

The spawn function will skip the very first item of the command array if it is NULL or if it contains a single character.

This has to do with that scratchpad commands start with a scratchkey character ("w" in the first example above) which are not part of the command.

If any part of the command starts with ~/ then the tilde character will be replaced with the value of the HOME environment variable.

The spawned program can also start in the working directory of the currently selected client if the selected client contains a file path in the window title.

Refer to the SpawnCwd functionality for more information.

There are no external commands for this function.


NB: While it is perfectly fine to bind application keybindings within the window manager using the spawn function you may want to consider moving your application keybindings to an external key handler such as sxhkd.

The benefits are that:

  • setting up keybindings is both easier and more flexible
  • application keybindings can be changed without the need to recompile or restart the window manager
  • the application keybindings are retained if you try out another window manager

Back to Functions > Window.

Clone this wiki locally