You are not logged in.

#1 2017-12-04 05:07:00

Cougarium
Member
Registered: 2017-12-04
Posts: 4

[SOLVED] DISPLAY variable is set before launching X server

I'm using i3 desktop and I am trying to start an X session at boot.

According to the Arch wiki page on xinit, placing this statement:

if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
  exec startx
fi

in my .bash_profile will launch the session when I login.

The issue I am running in to is that the "DISPLAY" variable is set to ":1" leading to this statement being skipped.

Here is my .bash_profile:

#
# ~/.bash_profile
#

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

if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -le 3 ]; then
        exec startx
fi

And here is my .bashrc:

#
# ~/.bashrc
#

export TERM="rxvt-unicode-256color"
export XDG_CONFIG_HOME="$HOME/.config"

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

if [ -f "$HOME/.config/powerline/powerline.sh" ]; then
        . $HOME/.config/powerline/powerline.sh
fi

alias ls='ls --color=auto'

PS1='[\u@\h \W]\$ '

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

if [ -f $HOME/.bash_aliases ]; then
    . $HOME/.bash_aliases
fi

Why is DISPLAY set before sourcing sourcing .bash_profile when it clearly shouldn't be? Thank you!

Last edited by Cougarium (2017-12-05 03:52:33)

Offline

#2 2017-12-04 05:44:51

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

Re: [SOLVED] DISPLAY variable is set before launching X server

The DISPLAY variable has no bearing on the code you are executing in your .bash_profile. Please paste the output of `ls -a $HOME`.

And, dont force your $TERM: it just breaks things.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2017-12-04 07:30:07

Cougarium
Member
Registered: 2017-12-04
Posts: 4

Re: [SOLVED] DISPLAY variable is set before launching X server

jasonwryan wrote:

The DISPLAY variable has no bearing on the code you are executing in your .bash_profile. Please paste the output of `ls -a $HOME`.

And, dont force your $TERM: it just breaks things.

..             Desktop        git            .npm                .ssh          .vscode
.bash_aliases  .dmrc          .gitconfig     .nv                 .subversion   .Xauthority
.bash_history  Documents      .gnupg         .nvm                Templates     .xinitrc
.bash_logout   Downloads      .ICEauthority  .omnisharp          test.txt      .Xresources
.bash_profile  .dropbox       .ipython       Pictures            Videos        .xserverrc
.bashrc        Dropbox        .lesshst       .pki                .vim          .xsession-errors
.bashrc.swp    .dropbox-dist  .local         .psql_history       .viminfo      .xsession-errors.old
.cache         .esd_auth      Music          Public              .viminfo.tmp
.compton.conf  .fehbg         .node-gyp      .python_history     .viminfz.tmp

How can the DISPLAY variable not have any bearing on .bash_profile? If it is not set (if the string's length is zero) is what is being checked here.

Offline

#4 2017-12-04 07:39:14

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] DISPLAY variable is set before launching X server

Cougarium wrote:

the "DISPLAY" variable is set to ":1"

That's weird.

Just to confirm: if you log into TTY1 (without the conditionals in .bash_profile) then `echo $DISPLAY` produces ":1"?

I use this test instead:

[ "$(tty)" = "/dev/tty1" ] && exec startx

Does that work for you?

Last edited by Head_on_a_Stick (2017-12-04 07:39:28)


Jin, Jîyan, Azadî

Offline

#5 2017-12-04 09:21:54

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,867

Re: [SOLVED] DISPLAY variable is set before launching X server

Well, it'll be set by powerline, nvm or (to a lesser probability) the bash_aliases - just echo $DISPLAY before and after every sourcing and you'll see ...

Offline

#6 2017-12-05 02:54:44

Cougarium
Member
Registered: 2017-12-04
Posts: 4

Re: [SOLVED] DISPLAY variable is set before launching X server

Head_on_a_Stick wrote:
Cougarium wrote:

the "DISPLAY" variable is set to ":1"

That's weird.

Just to confirm: if you log into TTY1 (without the conditionals in .bash_profile) then `echo $DISPLAY` produces ":1"?

I use this test instead:

[ "$(tty)" = "/dev/tty1" ] && exec startx

Does that work for you?

Correct. And explicitly launching X on TTY1 doesn't work either hmm

Offline

#7 2017-12-05 03:48:26

Cougarium
Member
Registered: 2017-12-04
Posts: 4

Re: [SOLVED] DISPLAY variable is set before launching X server

Alright, I didn't realize I couldn't have a GDM enabled. After disabling GDM the variable was not set.

Offline

Board footer

Powered by FluxBB