my current situation is that in my .zprofile file I have the following line I found somewhere on the internet

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

I think it's supposed to see if there is a display and if so it starts and x server which allow i3 window manager to run later on. This works great except for when I try to SSH in, as soon as I type in my password it errors out and closes the connection with the following message :

"Error Opening Display!"

I'm assuming this is because it's trying to start an x server upon login, how do I fix this? I'm assuming I need to change some things around so that startx isn't called if I'm ssh'ing in.

1 Answer 1


Check if $SSH_CLIENT is empty as well as $DISPLAY. For example:

[[ -z $DISPLAY && -z $SSH_CLIENT && $XDG_VTNR -eq 1 ]] && exec startx

Alternatively, use $SSH_CONNECTION or $SSH_TTY

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .