The .xinitrc file is really just one more shell script to run. It can be used to start various applications you want to associate with starting X, e.g. the X screensaver, and to set global environment variables, like MOZ_PLUGIN_PATH. It's foremost use however, is as a replacement for a display manager when on a single user machine. When you do not start a display manager it is important to keep in mind that the life of your X session starts and ends with the .xinitrc script. What this means is that once the script finishes, X quits, regardless of whether you still have running programs, including your window manager. It is therefore important that the window manager quitting and X quitting should coincide. This is usually achieved by running the window manager as the last thing in the .xinitrc script, e.g.
/usr/bin/xscreensaver -no-splash & /usr/lib/notification-daemon/notification-daemon & export MOZ_PLUGIN_PATH="/usr/lib/mozilla/plugins:/opt/mozilla/lib/plugins" exec openbox-session
Notice that the screensaver and the notification daemon are run in the background. Otherwise the script would halt and wait for the screensaver program to quit before continuing. The variable export line will run and quit very quickly. The line starting Openbox, however is not backgrounded. This ensures that the script will not quit until Openbox does. If you run the startx script manually ending the script will terminate x and leave you with whatever VCs your inittab has started. If you're running it from inittab and has set the line to 'respawn' (rather than 'once'), xinitrc will be run again. This way you can restart X without having to restart the computer.
#!/bin/sh # # ~~/.xinitrc # # 被startx执行 （从这里运行你的窗口管理器） # # exec ion # exec wmaker # exec startkde # exec icewm # exec blackbox exec gnome-session # exec startfluxbox # exec startxfce4 # exec openbox # exec startlxde
xinit /usr/bin/enlightenment -- -br +bs -dpi 96