Can't specify title of lxterminal running bash
Posted: 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/autostart.sh has only 1 un-commented line:
/home/j/.config/openbox/autostart_runs_this_in_bash.sh
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 --title=stuff.sh --geometry=76x19 -e /. . ./stuff.sh &
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:
If I open a terminal and paste that code directly in OR if I source it from a file with:
. set-title-func-file
then
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.
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/autostart.sh has only 1 un-commented line:
/home/j/.config/openbox/autostart_runs_this_in_bash.sh
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 --title=stuff.sh --geometry=76x19 -e /. . ./stuff.sh &
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
ORIG=$PS1
fi
TITLE="\[\e]2;$*\a\]"
PS1=${ORIG}${TITLE}
}
. set-title-func-file
then
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.