2

Is there a way to set a title to a terminal that is opend via desktop shortcut?

The perfect solution would be if the [Desktop Entry] Name=myTitle could be displayed in the title. Does anyone know if this is possible?

See also (approach here didn't work): desktop shortcut to terminal-app of another user possible?

based on this: Can no longer set terminal title in Ubuntu 16 (gnome-terminal)

Sebastian Stark
  • 6,122
  • 19
  • 48
ssssstut
  • 667

2 Answers2

0

Simplest solution I can think of based on my previous answers, would be to spawn terminal with command that sets title + spawns interactive shell of your choice. Specifically, I would make the Exec= part of the .desktop file as so:

Exec=gnome-terminal -e "bash -c 'printf \"\033]0;TEST1\007\";bash'"
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • Thanks for your suggestion! I'm new to Ubuntu, how can I accomplish this with my existing entry which starts an app zzz from another user xyz: ' Exec=bash -c 'su -c "/home/xyz/zzz -param1 " xyz; read -p "Hit Enter to close terminal:"' ' – ssssstut Jun 26 '18 at 20:08
  • @ssssstut So you probably should just add the printf part (which is what does setting the title of the terminal) before su. Specifically, with your example, I'd do Exec=bash -c 'printf \"\033]0;TEST1\007\"; su -c "/home/xyz/zzz -param1 " xyz; read -p "Hit Enter to close terminal:"' ' – Sergiy Kolodyazhnyy Jun 26 '18 at 20:24
  • doesn't work, says: "033]0bash: TEST1007": command not found (wants to exec ;TEST1 as cmd) – ssssstut Jun 26 '18 at 20:33
  • Alright. I'll try to fix it later. Right now using phone, so don't have terminal – Sergiy Kolodyazhnyy Jun 26 '18 at 20:38
  • resolved it: this did the trick: " Exec=bash -c 'printf "\033]0;TEST1\007"; su -c ..." --> shows the title TEST1 – ssssstut Jun 26 '18 at 21:36
0

Use

Exec=gnome-terminal -t myTitle -e myCommand ...

in your desktop file. See also the gnome-terminal help output:

$ gnome-terminal --help-terminal-options
Usage:
  gnome-terminal [OPTION…] [-- COMMAND …]

Terminal options; if used before the first --window or --tab argument, sets the default for all terminals:
  -e, --command                   Execute the argument to this option inside the terminal
  --profile=PROFILE-NAME          Use the given profile instead of the default profile
  -t, --title=TITLE               Set the initial terminal title
  --working-directory=DIRNAME     Set the working directory
  --wait                          Wait until the child exits
  --fd=FD                         Forward file descriptor
  --zoom=ZOOM                     Set the terminal’s zoom factor (1.0 = normal size)
Sebastian Stark
  • 6,122
  • 19
  • 48