You are not logged in.
Pages: 1


Ubuntu 26.04.1 LTS xfce 4.20
In the past , in a C program
printf("\033]0;%s\007]", pref);
would set the terminal window title.
But not now. It always shows
userid@pwd (with real user id and what pwd would show).
I don't know where that specification comes from.
If I use xterm instead I can set the window title, but have had no luck finding a settings page to
have correct colors and default window size.
Ideas?
Offline


printf("\033]0;%s\007]", pref);
In a bash shell, try
printf '\e]2;title\007\n'; readWorks in bash here and in Perl, should work in C, too, should work in any language. Note that I printed '\e]2;', number 2 instead of 0, but both numbers should work. Use the read command to have the shell wait for your enter key, because otherwiseyour text disappears as soon as the prompt is shown, too quick to notice.
Here: Debian trixie with Xfce 4.20.1 and Xfce-Terminal 1.1.4
Offline


The terminal in the panel says the command is:
exo-open --launch TerminalEmulator
/usr/bin/xfce4-terminal
behaves exactly the same, setting the title does nothing. So far.
Added later 02 min 27 s:
I did alter the code to do:
printf("\e]2;%s\007\n", "dd");
sort of as you suggested.
Should have said that in previous note.
Added later 04 min 40 s:
That newline you suggested did result in
a blank line in the terminal window, but the title
of the window is not affected.
Offline


One reason why the code might not work as previously, and works in xterm, might be related to your shell.
#include <stdio.h>
void main() {
const char *pref = "XFCE";
printf("\e]2;%s\007\n", pref);
}This works in bourne shell (sh) but not bash because bash uses the PROMPT_COMMAND environment variable to overwrite the title when your c program finishes. To test this, try adding in a sleep(3); after the printf command (so you can see the effect), or in bash, "unset PROMPT_COMMAND" and run the program.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline


Yes, right. It worked. Thank you.
Looking at $PROMPT_COMMAND, the default value is
__vte_prompt_command
which is not particularly meaningful (at least to me).
Added later 11 min 56 s:
I added
export PROMPT_COMMAND=""
to ~/.bashrc
and that worked. I hope it won't have other effects.
Last edited by dandelot (2026-10-06 01:22:51)
Offline


Looking at $PROMPT_COMMAND, the default value is
__vte_prompt_command
which is not particularly meaningful (at least to me).
On your system, PROMPT_COMMAND isn't being directly set, but rather, bash is using a vte built-in function. You can see the contents of this function via:
type __vte_prompt_command...which is probably defined somewhere in /etc/profile.d.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Pages: 1
[ Generated in 0.022 seconds, 10 queries executed - Memory usage: 564.52 KiB (Peak: 565.5 KiB) ]