Difference between revisions of "Talk:Xinit"

From ArchWiki
Jump to: navigation, search
(exec on last line…: close)
(/etc/profile.d/locale.sh: Close)
 
(68 intermediate revisions by 16 users not shown)
Line 1: Line 1:
== Backgrounding ==
+
== 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? [[User:Pid1|Pid1]] ([[User talk:Pid1|talk]]) 00:30, 26 July 2015 (UTC)
  
The article points out that any process (e.g. programs and daemons) preceding the 'exec WM/DE' statement should be backgrounded. This sounds logical in order to execute all of the desired statements (included the WM/DM launcher), without waiting for a process to exit. Looking at the file examples (some provided by myself), I noticed that 'xrdb ...' is not backgrounded. This made me test my own [https://github.com/roygbiiv/dotfiles/blob/master/.xinitrc config], without backgrounding anything except the 'xscreensaver' daemon statement, and the results are the same - only I don't have a lot of backgrounded processes when using 'ps -a'. This matter confuses me a little so, my question is: are there any general rule on what processes should be backgrounded in .xinitrc? Starting daemons is one example of processes that should be backgrounded. --[[User:Roygbiv|Roygbiv]] 16:55, 28 August 2011 (EDT)
+
:First of all, the first 4 points are inaccurate. Back in [https://wiki.archlinux.org/index.php?title=General_troubleshooting&diff=270284&oldid=239571 2013], this was indeed handled by the default {{ic|/etc/X11/xinit/xserverrc}}, which contained {{bc|<nowiki>
:I'm using [https://aur.archlinux.org/packages.php?O=0&K=urxvtcd&do_Search=Go urxvtcd] and it doesn't have to be backgrounded in order for dwm to start. If I use urxvt instead, dwm won't start unless I background urxvt or it starts only after I exit urxvt. -- [[User:Karol|Karol]] 17:13, 28 August 2011 (EDT)
+
#!/bin/sh
::Ok. So it isn't necessary to background all daemon processes. Looking at other processes though, it's not clear to me what to do. In the this talk page:[https://wiki.archlinux.org/index.php/Talk:X_resources xresources] there was an issue with backgrounding xrdb statements for intance. The solution was to not background it. I guess there isn't a general rule for all processes, because it depends how the different processes behave, but it seems backgrounding in most cases is more generally adviced to not override/delay the xinit process. I don't know here, maybe you got some more expericence. -- [[User:Roygbiv|Roygbiv]] 02:04, 29 August 2011 (EDT)
+
if [ -z "$XDG_VTNR" ]; then
 +
  exec /usr/bin/X -nolisten tcp "$@"
 +
else
 +
  exec /usr/bin/X -nolisten tcp "$@" vt$XDG_VTNR
 +
fi
 +
</nowiki>}}
 +
:Now it contains only {{bc|<nowiki>
 +
#!/bin/sh
 +
exec /usr/bin/X -nolisten tcp "$@"
 +
</nowiki>}}
 +
:This will be more work than it seemed, we should investigate... Nevertheless, ''startx'' handles the {{ic|vt}} parameter, but plain ''xinit'' doesn't, so I'd say the note is perfectly suitable for this page.
 +
:-- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 08:17, 26 July 2015 (UTC)
  
==<s>exec on last line…</s>==
+
::Thanks for the insights. I will cross-reference the documentation with what is provided here, and update accordingly. [[User:Pid1|Pid1]] ([[User talk: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 [[User:Ziusudra|Ziusudra]] ([[User talk:Ziusudra|talk]]) 00:19, 11 February 2016 (UTC)
  
Someone please explain AlexanderR that he shouldn’t revert edits blindly… See https://wiki.archlinux.org/index.php?title=Xinitrc&action=historysubmit&diff=241683&oldid=241177 I’m not up for this little game :( [[User:Stqn|Stqn]] ([[User talk:Stqn|talk]]) 15:15, 28 December 2012 (UTC)
+
== propose to add to automatic startx ==
  
:Eheh don't take it personally :) What AlexanderR means is that the note shouldn't try to teach what happens if a command is in a non-executed code block, and I agree with him.
+
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.
:In order to avoid an edit war, let's try to improve the wording here, my proposal is:
+
 
:{{Note|Make sure to uncomment only one {{ic|exec}} line, since that will be the last command run from the script; all the following lines will just be ignored.}}
+
{{bc|1=<nowiki>
:-- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 12:40, 29 December 2012 (UTC)
+
if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then
::Implemented, close. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 10:14, 13 April 2013 (UTC)
+
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
 +
else
 +
touch /tmp/login-check-startx.flag
 +
( sleep 120; rm /tmp/login-check-startx.flag ) &
 +
exec startx
 +
fi
 +
fi
 +
## Change '/tmp/login-check-startx.flag' to '$HOME/login-check-startx.flag' if you want that check also valid after reboot.
 +
</nowiki>}}
 +
 
 +
[[User:Triplc|Triplc]] ([[User talk: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: {{bc|<nowiki>
 +
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
 +
fi
 +
fi
 +
</nowiki>}}
 +
:Or even more simply, don't {{ic|exec startx}}, check its return code and drop to interactive shell on errors: {{bc|<nowiki>
 +
if [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]]; then
 +
startx && exit
 +
fi
 +
</nowiki>}} -- [[User:Lahwaacz|Lahwaacz]] ([[User talk: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 [[User:Triplc|Triplc]] ([[User talk:Triplc|talk]]) 21:36, 20 April 2016 (UTC)

Latest revision as of 06:09, 22 February 2018

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
#!/bin/sh
if [ -z "$XDG_VTNR" ]; then
  exec /usr/bin/X -nolisten tcp "$@"
else
  exec /usr/bin/X -nolisten tcp "$@" vt$XDG_VTNR
fi
Now it contains only
#!/bin/sh
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
	else
		touch /tmp/login-check-startx.flag
		( sleep 120; rm /tmp/login-check-startx.flag ) &
		exec startx
	fi
fi
## 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
	fi
fi
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
fi
-- 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)