From ArchWiki
Revision as of 11:54, 19 September 2017 by Alad (talk | contribs) (about "&" and "exec" in .xinitrc: close)
Jump to: navigation, search

about "&" and "exec" in .xinitrc

I doubt if they are absolutely/always necessary. It seems appropriate to me to emphasize or explain about them in this page. (I also question a bit about the correctness of the purpose and consequence stated in the explanation) -- Tom.ty89 2015-03-17 19:43 (UTC)

Feel free to make changes as you see fit. I took the existing "explanation" and reworded it for brevity, but it's as horrible as before. -- Alad (talk) 19:54, 17 March 2015 (UTC)
edit: I saw you already made some changes. Appreciated. -- Alad (talk) 19:57, 17 March 2015 (UTC)
exec for the window manager is necessary if the process forks into background, on the other hand appending & to other commands is not necessary when the process forks into background. I've tried to clarify that. -- Lahwaacz (talk) 16:34, 5 April 2015 (UTC)
I can't think of a way to explain this in the article now, but the forking thing is trickier than that: for example, you don't want to fork a command like xrdb -merge ~/.Xresources which usually ends up in xinitrc, otherwise the other applications that are started in the script may not be able to make use of Xresources because of the race condition. — Kynikos (talk) 13:57, 7 April 2015 (UTC)
It's a good example (and mentioned in X_resources#Parsing_.Xresources) - as an upside, xrdb is part of the default xinitrc and the article doesn't mention modifying it. -- Alad (talk) 14:21, 7 April 2015 (UTC)
I've added [1]. I wonder if Tom.ty89 is happy with the current state of the article, can we close this? — Kynikos (talk) 02:56, 8 April 2015 (UTC)

Running "Notes" Section

The two sets of notes at the bottom of xinitrc#Configuration should be condensed in some way. The first five bullet points all concern which tty X is running on. I could create this as its own subsection, and contain the information there, though I am not entirely convinced that this is necessary/appropriate/needed on this page at all. Would it be more appropriate to merge the relevant sections into the Xorg article, perhaps? Pid1 (talk) 00:30, 26 July 2015 (UTC)

First of all, the first 4 points are inaccurate. Back in 2013, this was indeed handled by the default /etc/X11/xinit/xserverrc, which contained
if [ -z "$XDG_VTNR" ]; then
  exec /usr/bin/X -nolisten tcp "$@"
  exec /usr/bin/X -nolisten tcp "$@" vt$XDG_VTNR
Now it contains only
exec /usr/bin/X -nolisten tcp "$@"
This will be more work than it seemed, we should investigate... Nevertheless, startx handles the vt parameter, but plain xinit doesn't, so I'd say the note is perfectly suitable for this page.
-- Lahwaacz (talk) 08:17, 26 July 2015 (UTC)
Thanks for the insights. I will cross-reference the documentation with what is provided here, and update accordingly. Pid1 (talk) 13:01, 26 July 2015 (UTC)
I've split this off into a new Running section. I think this section should be split into startx and xinit subsections and explain the details of using xinit in a way that is not a block of notes Ziusudra (talk) 00:19, 11 February 2016 (UTC)

propose to add to automatic startx

When combine automatic startx + automatic login to console, it may come to infinite loop/crash if (a) ~/.xinitrc goes wrong somewhere, after editing; or (b) after pacman -Syyu and Xorg crash. I propose to check if the last GUI session (startx session) really last long before start a new one.

if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then
	if [[ -f /tmp/login-check-startx.flag ]]; then
		rm /tmp/login-check-startx.flag
		echo -e "\nFile '/tmp/login-check-startx.flag' found, maybe the last GUI session did not last long!\n"
		## do nothing, start automatic console login
		touch /tmp/login-check-startx.flag
		( sleep 120; rm /tmp/login-check-startx.flag ) &
		exec startx
## Change '/tmp/login-check-startx.flag' to '$HOME/login-check-startx.flag' if you want that check also valid after reboot.

Triplc (talk) 20:42, 20 April 2016 (UTC)

You might do that without the temporary file by simply looking at the age of the log file:
if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then
	if [[ ! -e ~/.local/share/xorg/Xorg.0.log || $(find ~/.local/share/xorg/Xorg.0.log -mmin +2) != "" ]]; then
		exec startx
Or even more simply, don't exec startx, check its return code and drop to interactive shell on errors:
if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then
	startx && exit
-- Lahwaacz (talk) 21:10, 20 April 2016 (UTC)
Thanks Lahwaacz. But (a) so the age of a file is based on it's creation time, not update time. OK, i did not know that. (b) about the startx exit code, i am not sure that it will correctly set if i edit something wrong in ~/.xinitrc which make GUI session crash
I just tried to change the resolution of X (xrandr...) and ~/.local/share/xorg/Xorg.0.log updated and get the new timestamp Triplc (talk) 21:36, 20 April 2016 (UTC)


Should there be some mention of /etc/profile.d/ here? I had to add this to my .xinitrc file in order for my locale to load properly when using startx.

Archies (talk) 22:51, 12 September 2016 (UTC)

/etc/profile.d/ should be loaded by /etc/profile. Is the locale loaded at the point you run startx? -- Lahwaacz (talk) 06:38, 13 September 2016 (UTC)
I went ahead and commented the line out and tested my locale, it is now loaded before and after startx, whereas before /etc/profile.d/ was run the first time it was certainly not loaded after startx. This is across two separate installs of arch. I don't use a display manager and I did follow the installation guide thoroughly both times. I can't really explain it. This is the issue I was having and adding to my .xinitrc was what solved the issue. It's now commented out and locale still is loaded. I can't explain it. Archies (talk) 16:38, 13 September 2016 (UTC)