agkozak / polyglot

Color, ASCII-only Git prompt for zsh, bash, ksh93, mksh, pdksh, oksh, dash, yash, busybox ash, and osh
MIT License
181 stars 13 forks source link

Login fails (loop) #16

Closed schwabfk closed 1 year ago

schwabfk commented 2 years ago

Hello,

I wanted to test your script and installed it as suggested by inserting the respective line in the bashrc file, but this causes a login failure (opensuse tumbleweed, kde plasma, sddm). More specifically, at the login screen I enter my username and password (which both are correct), it seems to load the kde desktop but then jumps back to the login screen. Removing the script from the bashrc allows to login correctly again.

Do you have any ideas how to make your script your in such cases, because I really like its style!

agkozak commented 2 years ago

I haven't seen that problem before! Please start out by posting your .bashrc. Thanks.

edklem commented 2 years ago

agkozak, I have seen something like this before with gnome/gdm. I didn't think it was polyglot issue so I solved it using this in my .bashrc:

if tty -s
then 
    . /path/to/polyglot.sh
fi

That seemed to be all that was needed. I believe the issue is that the DE loads profiles like .bashrc on login - so the if tty -s just checks if you are loading .bashrc from a terminal/console (which the DE would not be) and then loads polyglot.sh. Something similar could be added at the beginning of the code to check if it's a console and exit if not...

schwabfk commented 2 years ago

agkozak, I have seen something like this before with gnome/gdm. I didn't think it was polyglot issue so I solved it using this in my .bashrc:

if tty -s
then 
    . /path/to/polyglot.sh
fi

That seemed to be all that was needed. I believe the issue is that the DE loads profiles like .bashrc on login - so the if tty -s just checks if you are loading .bashrc from a terminal/console (which the DE would not be) and then loads polyglot.sh. Something similar could be added at the beginning of the code to check if it's a console and exit if not...

That's it! I just added the lines as you suggested them, and now there is no problem anymore, thanks a lot.

@agkozak Perhaps you can add it as a "troubleshoot" to the readme.md?

agkozak commented 2 years ago

@edklem, thanks for providing @schwabfk with a quick fix.

@schwabfk, what's in your .bash_profile, .profile, and .bash_login files? Is there any possibility that one of them is sourcing .bashrc?

schwabfk commented 2 years ago

@edklem, thanks for providing @schwabfk with a quick fix.

@schwabfk, what's in your .bash_profile, .profile, and .bash_login files? Is there any possibility that one of them is sourcing .bashrc?

Sure, but as it is a complete new installation, they are pretty empty, but here you go: [only .profile and .bashrc, as .bash_profile and .bash_login do not exist in opensuse (as far as I know)]

.profile:

# Sample .profile for SUSE Linux
# rewritten by Christian Steinruecken <cstein@suse.de>
#
# This file is read each time a login shell is started.
# All other interactive shells will only read .bashrc; this is particularly
# important for language settings, see below.

test -z "$PROFILEREAD" && . /etc/profile || true

# Some applications read the EDITOR variable to determine your favourite text
# editor. So uncomment the line below and enter the editor of your choice :-)
#export EDITOR=/usr/bin/vim
#export EDITOR=/usr/bin/mcedit

# For some news readers it makes sense to specify the NEWSSERVER variable here
#export NEWSSERVER=your.news.server

# Some people don't like fortune. If you uncomment the following lines,
# you will have a fortune each time you log in ;-)

#if [ -x /usr/bin/fortune ] ; then
#    echo
#    /usr/bin/fortune
#    echo
#fi

.bashrc

    # Sample .bashrc for SUSE Linux
    # Copyright (c) SUSE Software Solutions Germany GmbH

    # There are 3 different types of shells in bash: the login shell, normal shell
    # and interactive shell. Login shells read ~/.profile and interactive shells
    # read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
    # settings made here will also take effect in a login shell.
    #
    # NOTE: It is recommended to make language settings in ~/.profile rather than
    # here, since multilingual X sessions would not work properly if LANG is over-
    # ridden in every subshell.

    test -s ~/.alias && . ~/.alias || true

    # polyglot bash colours
    if tty -s
    then 
      . /home/schwabfk/bash-polyglot/polyglot
    fi
agkozak commented 2 years ago

. home/schwabfk/bash-polyglot/polyglot

Should it be . home/schwabfk/bash-polyglot/polyglot.sh, or perhaps you renamed the script?

schwabfk commented 2 years ago

. home/schwabfk/bash-polyglot/polyglot

Should it be . home/schwabfk/bash-polyglot/polyglot.sh, or perhaps you renamed the script?

It's just renamed ;)

agkozak commented 2 years ago

It's just renamed ;)

Got it, thanks. OK, I'll have time to think about this a little later, and perhaps you can help me to troubleshoot more.

agkozak commented 1 year ago

@edklem and @schwabfk - I want to thank both of you for reporting this bug. It was a case of typing exit when I meant return! Sorry for any inconvenience.