Can't specify title of lxterminal running bash

LXTerminal is the standard terminal emulator of LXDE -
Posts: 45
Joined: Wed Aug 07, 2013 4:28 am
Location: Trantor

Can't specify title of lxterminal running bash

Postby Lew_Rockwell_fan » Tue May 23, 2017 9:37 pm

I have lxterminal 0.2.0-1 under openbox 3.6.1-1ubuntu2 under Ubuntu Xenial 16.04 LTS, 64 bit. Minimalist environment installed from the mini.iso and built up. Something, I suspect bash, is policing the titles of lxterminal windows running bash, specifically GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu), which is the default shell, and won't allow any titles other than "user@host: ~" or "LXTerminal".

If I start an instance of lxterminal with any of the regular commands for setting the title, I never even see the title I set. If I CHANGE the title with wmctrl, Openbox changes the title as instructed - but only for a tiny fraction of a second, almost too fast to see, and then it is changed back.

This does NOT happen with XTerm or Terminator, either started with a title option or changing the titles afterwards. If I use wmctrl to rename an lxterminal running tcsh or dash, it gets renamed, but when I exit tcsh or dash back to bash the name I set is replaced by the one bash likes. Those are the only shells I've tried.

I renamed (effectively deleted) my ~/.bashrc and my ~/.profile and rebooted. That made wmctrl effective, so I can probably track that problem down by trial and error commenting out parts. But it didn't effect the problem of -t and --title= options not working. I'm thinking of trying rolling back my bash version.

My ~/.config/openbox/ has only 1 un-commented line:
That script has a #!/bin/bash shebang, so I assume it runs in bash. But there is a line in it like this:
nohup lxterminal --geometry=76x19 -e /. . ./ &
and that works. So maybe it inherited something from the sh script that started it that made the difference. Not any variable I set, but maybe dash sets and exports some on its own.

Obxprop and xprop both confirm that the title is the one I see, not the one tried to make it.

This just started recently, about the time I upgraded the kernel from 4.4.0-75 to 4.4.0-78.

Looking for this with a search engine, the only thing I find is an old thread I started myself at ubuntuforums with a similar problem long ago. In that case, it only affected lxterminal instances invoked without an -e option and since I pretty much never needed to title a terminal without the -e option, it wasn't important. But now titling by any means doesn't work at all for any lxterminal window running bash.

Some examples of commands that give me a terminal titled either "LXTerminal" or "user@host:~"
$ lxterminal --title=geroge -e sleep 5
$ lxterminal -t geroge -e sleep 5
$ lxterminal -t "geroge" -e sleep 5
$ lxterminal --command="sleep 4" -t "geroge"
$ lxterminal --title=geroge -e sleep 5
$ lxterminal --title=geroge -e /bin/bash
$ lxterminal --command=/bin/bash -t "geroge"
$ sudo lxterminal --command=/bin/bash -t "geroge"
[sudo] password for j:
$ lxterminal -t "geroge" -e /bin/bash
$ wmctrl -r :ACTIVE: -T george
$ wmctrl -r :SELECT: -T UseMyTitleYouCursedWM

The strangest thing is the odd way this function works:

Code: Select all

function set-title(){
  if [[ -z "$ORIG" ]]; then

If I open a terminal and paste that code directly in OR if I source it from a file with:
. set-title-func-file
set-title george
works fine if entered manually, but it will not work in a bash script, regardless of whether the function is defined in the script itself or sourced. That's plum perplexing. I have not yet tried it in a tcsh script nor running a script in another kind of terminal.

It seems likely this is somehow related to prompt setting, given the "PS" in that function (which I didn't write and haven't really studied) and the fact that one of the 2 titles that are allowed looks suspiciously like the default bash prompt. I actually reset my prompt maybe 6 months back to just plain $ and # marks. So maybe that is coming from some kind of hard coded default deep in bash.

I'd appreciate any insights. Do any of these things that aren't working for me work for you? I'd prefer to get all 3 title setting mechanisms - the native -t and --title= options on starting the terminal, the function working from scripts running IN the terminal, and wmctrl commands from outside, but any of them would help. I don't really want to have to choose between bash and lxterminal.

Posts: 521
Joined: Mon Apr 08, 2013 6:45 am

Re: Can't specify title of lxterminal running bash

Postby drooly » Wed May 24, 2017 5:36 pm

i can confirm & reproduce.

also look in /etc/bash.bashrc and /etc/profile

Posts: 45
Joined: Wed Aug 07, 2013 4:28 am
Location: Trantor

Re: Can't specify title of lxterminal running bash

Postby Lew_Rockwell_fan » Thu May 25, 2017 3:48 pm

Thanks, Drooly. I wouldn't have thought of those 2 files. I'll post whatever I figure out.

Posts: 45
Joined: Wed Aug 07, 2013 4:28 am
Location: Trantor

other odd behaviours that I suspect are related

Postby Lew_Rockwell_fan » Thu May 25, 2017 7:40 pm

Investigating this, I stumbled across some things I suspect may be related:

1. Starting terminal emulator in a specific shell:

These commands work as expected, starting the terminal emulator using tcsh:

$ SHELL=/bin/tcsh xvt
$ SHELL=/bin/tcsh terminator
$ SHELL=/bin/tcsh rxvt
$ SHELL=/bin/tcsh xterm

But this does NOT - bash is used instead:

$ SHELL=/bin/tcsh lxterminal

2. WINDOWID environment variable

env | grep WINDOWID

All these terminals:
xvt, rxvt, terminator, xterm

set a variable WINDOWID.

LXTerminal does not.

env | grep -i WINDOW
shows no likely alternative like WINDOW_ID

There are still related things I haven't investigated, the results of which I will report in this thread. The odd, maybe related/maybe not related stuff, I'll probably edit into this post. I'll hold off reporting these things as bugs until I have a little more insight. Comments on any of this are welcome.

Posts: 45
Joined: Wed Aug 07, 2013 4:28 am
Location: Trantor

A work-around

Postby Lew_Rockwell_fan » Fri May 26, 2017 4:52 pm

I found I can run a wrapper script in the background (so lxterminal can't mess with it) to get the title option working when invoking lxterminal. The wrapper must have a shebang that points to something besides bash. Both tcsh and dash work. I haven't investigated other shells yet. The shebang in the script invoked doesn't matter - it can run bash in a user titled lxterminal just fine. I'll add an example pair of scripts to this post later.

I suspect all of this is related - bash is behaving badly & lxterminal is abetting it.

It may be possible to tame bash, but out of the box, the general principles seem to be:

-Keep bash out of it completely until the windows you want to title are already drawn.
-Lxterminal always STARTS running bash, ignoring any instructions to the contrary. You can change the shell with the first command. You can pass on the first command with an -e option when invoking it. But it still STARTS running bash.
-Changing the shell once lxterminal is running will not banish bash's evil influence.

Therefore you can start an lxterminal with an effective title command from, for example, a dash script that doesn't have any bash ancestry. The shell running in the lxterminal doesn't matter. Bash's influence starts the first it helps draw a terminal window, not from the first time it is invoked. You can retitle that window with wmctrl also. But you cannot start another lxterminal FROM commands run in that window and have control of the titling. Once bash gets control of the window title of an lxterminal, it won't let go, and more lxterminals started from that one, will be bastard sons of bash, even if their mother is a dash shebang.

For the "lxterminal -t" type commands to work, they must run in a script that is not running under bash AND is not running in an lxterminal. So the FIRST lxterminal in a chain of scripts can be invoked with a user-chosen title and can be retitled any number of times with wmctrl. But any new lxterminals invoked FROM it cannot. Clear as mud, right?

This summary may need to be refined a bit, but I'm pretty sure it is approximately correct. This is actually a usable work-around even if it is a bit weird and convoluted.
Last edited by Lew_Rockwell_fan on Fri May 26, 2017 10:17 pm, edited 3 times in total.

Posts: 45
Joined: Wed Aug 07, 2013 4:28 am
Location: Trantor

Re: Can't specify title of lxterminal running bash

Postby Lew_Rockwell_fan » Fri May 26, 2017 5:13 pm

Might also be related to permissions, because this works:

sudo lxterminal -T mytit -e

but it runs the whole script as root. Possibly I can use it as a wrapper to do something like;

sudo -u username -H -e

I'll revise this post after I try that.

Return to “LXTerminal”

Who is online

Users browsing this forum: No registered users and 1 guest