zshを使ってxを起動するには?

zshを使ってxを起動するには?

初めてログインしたときにxを自動的に起動したいと思いますzsh

追加した後

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

ファイルとして~/.zprofile。ただし、xinitがi3を起動するまで2回ログインする必要があります。

ところで、私はArchを使用します

私の.xinitrc姿

#!/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

ベストアンサー1

私は答えが遅れていましたが、同じ問題を偶然発見し、OPと同じであると疑われるユースケースに迅速な解決策を提供したかったのです。明確にすると、これは「テキストモード」を使用してログインした直後にXorgを起動することです。したがって、gdmやlightdmなどのディスプレイマネージャはありません。

あなたがすべきことは、最後に次の行を追加することだけです.zshrc

if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then 
  exec startx &>/dev/null 
fi

デフォルトでは、Xorgがまだ起動しておらず、tty1にある場合は、Xorgを実行するだけです(迷惑な出力なしで...)。後者は、Xorgが起動時に失敗し、いくつかの設定ファイルを変更する必要がある場合に使用されます(私の考えには非常に便利です...)。

お役に立てば幸いです。

注:Bashでも同じコードを使用できます。

おすすめ記事