Bug 1076927

Summary: XFCE Terminal does not update the tittle correctly
Product: [openSUSE] openSUSE Tumbleweed Reporter: Carlos Robinson <carlos.e.r>
Component: BasesystemAssignee: Dr. Werner Fink <werner>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Minor    
Priority: P5 - None CC: carlos.e.r, seife
Version: CurrentFlags: werner: needinfo? (carlos.e.r)
Target Milestone: ---   
Hardware: Other   
OS: openSUSE Factory   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Screenshot demonstrating the problem

Description Carlos Robinson 2018-01-21 22:02:02 UTC
Created attachment 756971 [details]
Screenshot demonstrating the problem

Since some months the XFCE Terminal application does not update the tittle correctly. For instance, I "su -" but the tittle shows "terminal - user@hostname", where it should show "terminal - root@hostname" (see attached photo).

This also affects Leap 42.2 and 42.3, after some of the mandatory updates, but it worked correctly after the initial install and for some months.
Comment 1 Stefan Seyfried 2018-01-22 09:19:54 UTC
The "dynamically set title" xfce4-terminal is "just" the ANSI hardstatus line feature.

So if this:

printf '\e]0;XFCE4-TERMINAL-TEST\007'; sleep 10

changes your title for 10 seconds, xfce4-terminal is working as intended.

(actually if changing to another directory is reflected in the terminal title, it's working as expected as /etc/profile.d/vte.sh sets the corresponding PROMPT_COMMAND to display CWD in hardstatus).

Does the above command change your terminal title?
Comment 2 Carlos Robinson 2018-01-23 13:17:36 UTC
Yes, of course that command works.

But previously the tittle bar followed automatically the user and host that is currently logged into that terminal, and that doesn't happen now in any of my updated machines.

It tracks the directory, but not the user and the hostname, as it happened six months ago.
Comment 3 Carlos Robinson 2018-01-23 14:01:12 UTC
LXTerminal follows the changes.
Xterm follows the changes.
Konsole follows the changes from ssh, but not from su.
Comment 4 Stefan Seyfried 2018-01-24 09:03:47 UTC
Not an XFCE problem.
xfce4-terminal is working as expected, something else (the prompt setup?) has probably changed.

You can compare the environments in the different terminals (save "set" output to a file and compare) and try to find out what exactly causes the difference.

Once you found the difference, the setup script in /etc/profile.d (guessed by me) that causes the differnce will lead you to the correct component / package to assign this bug to.
Comment 5 Carlos Robinson 2018-01-24 12:05:42 UTC
Probably this:

XFCE term

SHLVL=1
TERM=xterm-256color
UID=1001
USER=carlos-e

...

ppwd () 
{ 
    true
}


xterm:

SHLVL=1
TERM=xterm
TS1=$'\E7\E]2;%s@%s:%s\a\E]1;%s\a\E8'
UID=1001
USER=carlos-e



I don't know who sets ppwd:


carlos-e@Tumbleweed:/etc/profile.d> grep ppwd *
carlos-e@Tumbleweed:/etc/profile.d> 

ppwd () 
{ 
    local dir;
    local -i width;
    test -n "$TS1" || return;
    dir="$(dirs +0)";
    let width=${#dir}-18;
    test ${#dir} -le 18 || dir="...${dir#$(printf "%.*s" $width "$dir")}";
    if test ${#TS1} -gt 17; then
        printf "$TS1" "$USER" "$HOST" "$dir" "$HOST";
    else
        printf "$TS1" "$USER" "$HOST" "$dir";
    fi
}



It appears to be /etc/bash.bashrc


        #
        # Set xterm prompt with short path (last 18 characters)
        #
        if path tput hs 2>/dev/null || path tput -T $TERM+sl hs 2>/dev/null ; then
           ...
           ppwd ( ...
        else
           ppwd () { true; }
        fi


cer@Tumbleweed:/etc> rpm -qf /etc/bash.bashrc 
aaa_base-84.87+git20171201.65000be-2.1.x86_64

cer@Tumbleweed:/etc>
Comment 6 Carlos Robinson 2018-01-24 12:43:53 UTC
Errata in copypaste:

xterm set has:

SHLVL=1
TERM=xterm
TS1=$'\E7\E]2;%s@%s:%s\a\E]1;%s\a\E8'
UID=1001
USER=carlos-e

...

ppwd () 
{ 
    local dir;
    local -i width;
    test -n "$TS1" || return;
    dir="$(dirs +0)";
    let width=${#dir}-18;
    test ${#dir} -le 18 || dir="...${dir#$(printf "%.*s" $width "$dir")}";
    if test ${#TS1} -gt 17; then
        printf "$TS1" "$USER" "$HOST" "$dir" "$HOST";
    else
        printf "$TS1" "$USER" "$HOST" "$dir";
    fi
}
Comment 7 Dr. Werner Fink 2018-06-19 12:01:18 UTC
Here it simply works:

 werner@noether:~> TERM=xterm              
 werner@noether:~> source /etc/bash.bashrc 
 werner@noether:~> cd /tmp/
 werner@noether:/tmp> 

and I see the correct title

 werner@noether:/tmp> echo $PS1
 \[$(ppwd)\]\u@\h:\w>
 werner@noether:/tmp> set -x; ppwd; set +x
 + ppwd
 + local dir
 + local -i width
 + test -n ''
 ++ dirs +0
 + dir=/tmp
 + let width=4-18
 + test 4 -le 18
 + test 24 -gt 17
 + printf '' werner noether /tmp noether
 + set +x

... here in bash.bashrc the code check if the terminal info entry supports a status line:

 werner@noether:/tmp> tput -T $TERM hs
 werner@noether:/tmp> echo $?
 1
 werner@noether:/tmp> tput -T $TERM+sl hs
 werner@noether:/tmp> echo $?
 0

There is no xterm-256color entry with a status line

 werner@noether:/tmp> tput -T xterm-256color hs
 werner@noether:/tmp> echo $?
 1

show me how to detect that the current terminal emluator supports a status line?
Comment 8 Stefan Seyfried 2018-06-19 18:15:30 UTC
xfce4-terminal uses libvte to implement the terminal.

I think it might have to do with this change to the vte package:

* Do Dez 18 2014 zaitor@opensuse.org
- Update to version 0.39.1:
...
  + pty: Default to TERM=xterm-256color.

Carlos, do you still have an un-updated installation that does not show this problem for you?
If yes, can you please check the TERM variable in xfce4-terminal in this installation?
Comment 9 Dr. Werner Fink 2018-06-20 09:04:53 UTC
Hmm ... I could change The $TERM+sl to something like ${TERM%%-*}+sl
Comment 10 Carlos Robinson 2018-06-20 09:22:06 UTC
In order to check, I have migrated one of my 42.2 machines under vmware to virtualbox. The title bar changes accordingly, and these are the settings for user and root (su -).

Eleanor-422:~ # set | grep TERM
COLORTERM=1
TERM=xterm
Eleanor-422:~ # logout
carlos-e@Eleanor-422:~> set | grep TERM
COLORTERM=xfce4-terminal
TERM=xterm
carlos-e@Eleanor-422:~>

carlos-e@Eleanor-422:~> echo $SHLVL $TERM $UID $TS1 $ppwd
2 xterm 1001 
carlos-e@Eleanor-422:~> set | grep TS1
TS1=$'\E7\E]2;%s@%s:%s\a\E]1;%s\a\E8'
    test -n "$TS1" || return;
    if test ${#TS1} -gt 17; then
        printf "$TS1" "$USER" "$HOST" "$dir" "$HOST";
        printf "$TS1" "$USER" "$HOST" "$dir";
carlos-e@Eleanor-422:~> 


The suggested command sequence on 42.2:

carlos-e@Eleanor-422:~> echo $PS1
\[$(ppwd)\]\u@\h:\w>
carlos-e@Eleanor-422:~>

carlos-e@Eleanor-422:~> set -x; ppwd; set +x
+ ppwd
+ local dir
+ local -i width
+ test -n ''
++ dirs +0  
+ dir='~'   
+ let width=1-18
+ test 1 -le 18 
+ test 24 -gt 17
+ printf '' carlos-e Eleanor-422 '~' Eleanor-422
+ set +x
carlos-e@Eleanor-422:~> tput -T $TERM hs
carlos-e@Eleanor-422:~> echo $?
1
carlos-e@Eleanor-422:~> tput -T $TERM+sl hs
carlos-e@Eleanor-422:~> echo $?
0
carlos-e@Eleanor-422:~> tput -T xterm-256color hs
carlos-e@Eleanor-422:~> echo $?
1
carlos-e@Eleanor-422:~>


The same command sequence in Leap 42.3 produces errors and some differences (fresh xfce-terminal):


cer@Telcontar:~> echo $PS1
\[$(ppwd)\]\u@\h:\w>
cer@Telcontar:~> set -x; ppwd; set +x
+ ppwd
+ true
+ set +x
cer@Telcontar:~> tput -T $TERM hs
cer@Telcontar:~> echo $?
1
cer@Telcontar:~> tput -T $TERM+sl hs
tput: unknown terminal "xterm-256color+sl"
cer@Telcontar:~> echo $?
3
cer@Telcontar:~> tput -T xterm-256color hs
cer@Telcontar:~> echo $?
1
cer@Telcontar:~> 



However:


cer@Telcontar:~> TERM=xterm
cer@Telcontar:~> source /etc/bash.bashrc
cer@Telcontar:~> cd /tmp/
cer@Telcontar:/tmp> su -
Password:                     Tittle bar is correct here (displays "root...", both user and path)
Telcontar:~ # logout
cer@Telcontar:/tmp> echo $PS1
\[$(ppwd)\]\u@\h:\w>
cer@Telcontar:/tmp> set -x; ppwd; set +x
+ ppwd
+ local dir
+ local -i width
+ test -n ''
++ dirs +0
+ dir=/tmp
+ let width=4-18
+ test 4 -le 18
+ test 24 -gt 17
+ printf '' cer Telcontar /tmp Telcontar
+ set +x
cer@Telcontar:/tmp> tput -T $TERM hs
cer@Telcontar:/tmp> echo $?
1
cer@Telcontar:/tmp> tput -T $TERM+sl hs
cer@Telcontar:/tmp> echo $?
0
cer@Telcontar:/tmp> tput -T xterm-256color hs
cer@Telcontar:/tmp> echo $?
1
cer@Telcontar:/tmp> 



Is this the info you wanted?
Comment 11 Stefan Seyfried 2018-06-20 11:16:14 UTC
Hi Carlos,

the 42.2 where it works for you has TERM=xterm

xterm has a hardstatus line in termcap/terminfo, so the prompt is set accordingly
xterm-256color (as in the 42.3) has no hadstatus line in terminfo, so it says "i cannot display this" and the prompt is also set accordingly.

Probably 42.2 has a libvte-2_91-0 version older than 0.39.1, and thus sets TERM=xterm, later versions have gotten an update (probably 0.44.2, at least that's what is in SLES12-SP2+) and set TERM=xterm-256color
Comment 12 Dr. Werner Fink 2018-09-11 10:01:08 UTC
Meanwhile fixed in TW