You are not logged in.

#1 2017-03-08 21:13:43

Lemongrass
Member
From: Central Europe
Registered: 2017-03-03
Posts: 59

[Solved] Can't autostart X and Xfce4

I'm quite new to Arch, I installed it yesterday, and reinstalled today. I have a problem: I couldn't set X and Xfce4 to start automatically after/before login. What I do now is log in via terminal as my non-root user, then type startxfce4. It's fine afterwards.

I tried to solve this reading the Wiki. I have done these:

1. I created a .xserverrc in the home folder of my non-root user:

#!/bin/sh
exec /usr/bin/Xorg -nolisten tcp "$@" vt$XDG_VTNR

2. I copied /etc/X11/xinit/xinitrc to ~/.xinitrc and appended a few commans after it:

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then







    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then







    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login
xscreensaver &
exec startxfce4

Honestly, I think the problem will be here. The Wiki said a line won't get executed after an exec line. But the wiki also said: copy and append. So I'm not sure about this.

3. I copied /etc/skel/.bash_profile to ~/.bash_profile and added the recommended lines:

#
# ~/.bash_profile
#

[[ -f ~/.bashrc ]] && . ~/.bashrc

# autostart X at login
if [ -z "DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
	exec startx
fi

4. I've also tried this: Automatic login to virtual console but I didn't like the autologin feature, so I renamed the auto login config file with a .ooo ending to disable it.

Could you please help me with this issue? Thank you in advance. smile If I'm doing redundant things (the same setting in multiple config files), please warn me. smile

Last edited by Lemongrass (2017-03-09 19:50:06)

Offline

#2 2017-03-08 21:20:54

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [Solved] Can't autostart X and Xfce4

Use .xserverrc or .bash_profile, not both.

Your .xinitrc is broken: you are trying to background a window manager (twm): remove that, the clock and the xterm calls.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2017-03-09 09:43:52

Lemongrass
Member
From: Central Europe
Registered: 2017-03-03
Posts: 59

Re: [Solved] Can't autostart X and Xfce4

Hi, jasonwryan, thank you for helping smile

I tried fixing it as you said. I removed .bash_profile (since I created it). The .xserverrc remained unchanged. My .xinitrc looks like this:

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then







    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then







    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

#appended to autostart Xfce4
xscreensaver &
exec startxfce4

as you said.

I tried if it was broken with cat .xinitrc | bash, the result was this (Xfce4 was running then, next time when I start my computer, I try running this before running startxfce4):

/usr/bin/startxfce4: X server already running on display :0.0
xscreensaver: 10:31:41: already running on display :0.0 (window 0x2000006)
 from process 563 (andor@Lemongrass-pc).
xfce4-session: Another session manager is already running
[andor@Lemongrass-pc ~]$ cat /etc/X11/xinit/xinitrc 

However, my /etc/X11/xinit/xinitrc, from which I have copied my .xinitrc, seems just as broken as the one I posted in my first post. Couldn't be the problem that my OS is trying to run that? So this is it:

#!/bin/sh

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then







    xrdb -merge $sysresources

fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then







    xrdb -merge "$userresources"

fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# start some nice programs

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
 for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
  [ -x "$f" ] && . "$f"
 done
 unset f
fi

twm &
xclock -geometry 50x50-1+1 &
xterm -geometry 80x50+494+51 &
xterm -geometry 80x20+494-0 &
exec xterm -geometry 80x66+0+0 -name login

Should I remove the last 5 lines here?

And can I experiment with such things (editing global config files) in your opinion without asking you, experienced Archers first, or am I going to break my system? Thank you in advance. smile

Edit: additional info: I installed X like this:
pacman -S xorg-server xorg-server-utils xf86-video-intel xf86-input-synaptics xf86-video-vesa
xf86-video-vesa was installed a bit later.
xfce4-goodies are not installed on my OS.

Last edited by Lemongrass (2017-03-09 10:05:37)

Offline

#4 2017-03-09 10:41:03

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,475

Re: [Solved] Can't autostart X and Xfce4

There is no need to touch anything in /etc/*, .xinitrc in your home gets preference over that.
Don't remove .bash_profile. AFAIK you cannot autostartx from xserverrc as it is not read before starting x. While bash_profile is read at login, so you can auto-startx once you login.

Offline

#5 2017-03-09 12:41:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: [Solved] Can't autostart X and Xfce4

If you are using xfce, don't bother with startx and .xinitrc.  Just change the line in your .bash_profile to do what you already know works.  You say you can log in, then run `startxfce4`, so just automate that:

# autostart X at login
if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
	exec startxfce4
fi

That's it.

However, given this is in .bash_profile, there is no reason to use the separate binary "[", use bash's builtin "[[" instead.  Firther, the second conditional is completely superfluous, and note the typo I fixed in the first.  In reality the following single line will suffice in your .bashrc (get rid of the other conditional block and don't bother with startx  xinitrc or xserverrc):

[[ $XDG_VTNR -eq 1 && -z $DISPLAY ]] && exec startxfce4

"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2017-03-09 19:52:18

Lemongrass
Member
From: Central Europe
Registered: 2017-03-03
Posts: 59

Re: [Solved] Can't autostart X and Xfce4

Hi Trilby and Docbroke, thank you for stopping by. I could fix the issue with your help. smile

I've copied back the .bash_profile from /etc/.... and edited as Trilby said.

How did you see that typo? big_smile I understand that you have a parrot as profile picture, Trilby, but this needs eagle-eye. wink

Thank you especially for explaining me a bit what these files do.

Last edited by Lemongrass (2017-03-09 19:53:12)

Offline

Board footer

Powered by FluxBB