0

I want zsh to start x automatically on the first login.

After I added

if systemctl -q is-active graphical.target && [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
  exec startx
fi 

to the file ~/.zprofile. however I need to login twice until xinit starts i3.

BTW I use Arch

my .xinitrc looks like

#!/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
xrandr --output DP-3 --same-as LVDS-1 
exec i3
  • I don't know what you have, But if you have kali, you can use startx, and with other distros, you can start gdm or kdm. – PersianGulf Oct 17 '19 at 14:00
  • So do you mean I can just omit the if block. BTW I use arch – A.Dumas Oct 17 '19 at 14:20
  • You only need start gdm3 service via service gdm3 start – PersianGulf Oct 17 '19 at 14:40
  • Please explain your requirements in the question. On your system X should not be started until a user logs in who happens to use zsh? Do you want to run a display manager that requires a graphical login or do you want to directly associate the X server with the user who started it? – Bodo Oct 17 '19 at 14:41
  • I don't understand what you're trying to do here. Do you want a login prompt in text mode or graphical mode? If you have a text mode prompt, systemctl -q is-active graphical.target would be false. – Gilles 'SO- stop being evil' Oct 17 '19 at 19:47
1

I reformulate slightly, hopefully keeping the Q's spirit:

How to start X by a shell command? How to do it at system startup?

I ignore your systemctl and much of your .xinitrc.

The most basic user command is xinit. It is hard to say what it does, exactly. It has a special semantic and syntax. To answer the Q:

xinit fvwm does start x server.

It defaults to xinit fvwm -- X :0 which means as much as:

Initialize X SERVER "X" on DISPLAY "0" with window MANAGER fvwm

It has to be so complicated, because it is powerful. X server and a window manager turn a TTY into a so-called DISPLAY.

If you go only xinit, you get that special xclock-only environment. (without any "hidden" defaults, of course. See man xinit. Also man startx. Compare!).

Of course you need xorg.conf configured! (gpu card, input devices for x)

Of course you need a window manager`, (minimally) configured! (fvwm, twm, ...)

To start X via xinit automatically, it takes some of planning and negotiating with systemd and your distro. Out of scope, but only for now.

"start x on the first login" needs (much) more precision; if it means have x running on tty1 I can understand what it means, at least. I don't see much connection with a certain shell like zsh.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.