Sourcing xprofile from a session started with xinit The xprofile files are natively sourced by the following display managers: The xprofile file is similar in style to xinitrc. See also Display manager#Starting applications without a window managerĪn xprofile file, ~/.xprofile and /etc/xprofile, allows you to execute commands at the beginning of the X user session - before the window manager is started. Tip: This can be useful to launch graphical games, where excluding the overhead of a compositor can help improve the game’s performance. With this method you need to set each application’s window geometry through its own configuration files (if possible at all).
The following example shows how to start a particular desktop environment or window manager with an argument:Īlternatively the binary can be called directly from the command prompt as described in #Override xinitrc]( If you are frequently switching between different desktop environments or window managers, it is convenient to either use a display manager or expand ~/.xinitrc to make the switching possible. Switching between desktop environments/window managers Tip: This method can be combined with automatic login to virtual console Decide whether this matters to you before implementing the above.Īnd Systemd/User#Automatic login into Xorg without display manager Warning: Without exec, anyone that can kill X can get a shell and access to files in your home directory. If you would like to remain logged in when the X session ends, remove exec.
You can replace the -eq comparison with one like -le 3 (for vt1 to vt3) if you want to use graphical logins on more than one virtual terminal.Īlternative conditions to detect the virtual terminal include "$(tty)" = “/dev/tty1”, which does not allow comparison with -le, and "$(fgconsole 2>/dev/null || echo -1)" -eq 1, which does not work in serial consoles Therefore it is recommended to specify vt$XDG_VTNR in the ~/.xserverrc file: With logind and to prevent bypassing the screen locker by switching terminals, Xorg has to be started on the same virtual terminal where the login occurred. In order to maintain an authenticated session Both startx and xinit execute ~/.xserverrc if it exists, startx will use /etc/X11/xinit/xserverrc otherwise. The xserverrc file is a shell script responsible for starting up the X server. Prepending exec will replace the script process with the window manager process, so that X does not exit even if this process forks to the background. Note that some programs should instead not be forked, to avoid race bugs, as is the case of xrdb. Otherwise, the script would halt and wait for each program to exit before executing the window manager or desktop environment. Long-running programs started before the window manager, such as a screensaver and wallpaper application, must either fork themselves or be run in the background by appending an & sign. Note: At the very least, ensure that the last if block in /etc/X11/xinit/xinitrc is present in your ~/.xinitrc file to ensure that the scripts in /etc/X11/xinit/xinitrc.d are sourced. Therefore, to start a different window manager or desktop environment, first create a copy of the default xinitrc in your home directory: This default xinitrc will start a basic environment with Twm, xorg-xclock and Xterm (assuming that the necessary packages are installed). Otherwise startx will run the default /etc/X11/xinit/xinitrc. If it is present in a user’s home directory, startx and xinit execute it. ~/.xinitrc is handy to run programs depending on X and set environment variables on X server startup. If you do not provide one they will look for ~/.xinitrc to run as a shell script to start up client programs. Xinit and startx take an optional client program argument, see #Override xinitrc.
Display managers start Xorg for you and generally source xprofile. While you can also use xinit to run GUI applications without a window manager, many graphical applications expect an EWMH compliant window manager. Xinit is typically used to start window managers The startx script is a front-end for xinit.
The xinit program allows a user to manually start an Xorg display server.