-1

I use a bash script (konsole-name.sh) to change a terminal name, like this:

#!/usr/bin/bash
echo -en "\e]30;$1\a"

and I wanted to use the same method from a perl script that I use to check the GPU temperature, so that it updates periodically the window title.

Yet I didnt find a way. I tried both this:

$comm='echo -en "\e]30;T=$t\a"';
`$comm`;

and this, using my bash script:

$comm="konsole-name.sh T=$t";
`$comm`;

there is some way to do it?

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
alessandro
  • 3,838
  • 8
  • 40
  • 59
  • The console escape sequences work by printing text to the terminal. Backticks gobble up the output of the script. Most likely you just want `print "\e]30;$1\a";` from within Perl. – Corion Nov 14 '18 at 13:00
  • how stupid not to see it! Thanks that was exectly it – alessandro Nov 14 '18 at 13:11
  • 1
    [Term::Title](https://metacpan.org/pod/Term::Title) might be of interest. – Shawn Nov 14 '18 at 14:22

1 Answers1

5

The console escape sequences work by printing text to the terminal. In your case, the backticks gobble up the output of the script.

Most likely you just want print "\e]30;$1\a"; from within Perl:

my $title = "Fancy terminal title";
print "\e]30;${title}\a";
Corion
  • 3,855
  • 1
  • 17
  • 27
  • 2
    For the record, since this question is highly ranked on google: if using XTerm or Gnome Terminal, the proper escape sequence is `echo -ne "\e]2;$1\a"` instead – MestreLion Nov 26 '21 at 15:34