Closed eantowne closed 6 days ago
Tested with gnome-terminal v3.46.8: gnome-terminal --tab
opens a new tab in an existing gnome-terminal window only, when issued within gnome-terminal. When issuing gnome-terminal --tab
in another application, for example xterm or GNS3, it always opens a new window, never a new tab.
There is a hack to open a gnome-terminal tab even when using other programs: When you manage to find out the environment variables GNOME_TERMINAL_SERVICE
and GNOME_TERMINAL_SCREEN
of a gnome-terminal window and add these to the environment of the gnome-terminal --tab
command, then a new tab in that gnome-terminal window is opened. But I see no easy way to achieve that.
The easiest way is to forget about gnome-terminal and use mate-terminal instead. GNS3 already includes the settings for mate-terminal to open new tabs.
thanks @b-ehlers that worked. Appreciated.
I have tried a few workarounds but unfortunately I couldn't find anything that can be done by GNS3 to make gnome-terminal work with tabs :(
Our default terminal on Linux is xterm excepting on Debian, Ubuntu and Linux Mint (cf. code extract from GNS3 GUI)
if sys.platform.startswith("linux"):
distro_name = distro.name()
if distro_name == "Debian" or distro_name == "Ubuntu" or distro_name == "LinuxMint":
DEFAULT_TELNET_CONSOLE_COMMAND = PRECONFIGURED_TELNET_CONSOLE_COMMANDS["Gnome Terminal"]
I propose to switch to mate-terminal by default for these and also have mate-terminal as a dependency for our gns3-gui Debian package (or at least a recommended dependency).
As an experiment I created gnome-terminal-tab, which is a wrapper around gnome-terminal, that will open a new tab. But this just for testing.
Yeah, mate terminal works perfectly. Same problem with kde konsole. Always open to a new window.
Same problem with kde konsole. Always open to a new window.
To open a new tab in konsole the option --new-tab
is used. konsole --help
shows:
--new-tab Create a new tab in an existing window rather than
creating a new window ('Run all Konsole windows in
a single process' must be enabled)
So within Konsole in Settings
/ Configure Konsole...
/ General
the option Run all Konsole windows in a single process
must be enabled to open new consoles in tabs. By default this setting is disabled, then the option --new-tab
won't work and new windows will be created.
Thanks, looks like we gonna have to implement something similar to https://github.com/GNS3/gns3-gui/files/11382898/gnome-terminal-tab.txt
Thanks, looks like we gonna have to implement something similar to https://github.com/GNS3/gns3-gui/files/11382898/gnome-terminal-tab.txt
Please note, that gnome-terminal-tab just got some limited testing in my environment. I don't know if it works with wayland. And it my choose the wrong display, especially when you are doing remote logins by ssh to the GNS3-GUI system.
Personally I won't try to work around the limitations of gnome-terminal. I just would recommend mate-terminal (or any of the others terminal emulators offering working tab support).
I have added a working PR. Gnome-terminal must be configured to open new terminals in Tab.
I am still hesitating to switch to mate-terminal by default. I guess we could if it has already been installed.
Gnome-terminal must be configured to open new terminals in Tab.
Actually there is no need for that. I had mistaken the -t
parameter for --tab
Hello, today I get the update with the new function for gnome-terminal and works well.
A question, when I open the first terminal I can get gnome-terminal attention but if I open the second there is not windows attention. Is required any configuration?
I noticed the same behavior, the gnome-terminal window is not focused when opening more tabs... from what I read it is the standard behavior on Gnome, I haven't found a work-around.
Tested with gnome-terminal v3.46.8:
gnome-terminal --tab
opens a new tab in an existing gnome-terminal window only, when issued within gnome-terminal. When issuinggnome-terminal --tab
in another application, for example xterm or GNS3, it always opens a new window, never a new tab.There is a hack to open a gnome-terminal tab even when using other programs: When you manage to find out the environment variables
GNOME_TERMINAL_SERVICE
andGNOME_TERMINAL_SCREEN
of a gnome-terminal window and add these to the environment of thegnome-terminal --tab
command, then a new tab in that gnome-terminal window is opened. But I see no easy way to achieve that.The easiest way is to forget about gnome-terminal and use mate-terminal instead. GNS3 already includes the settings for mate-terminal to open new tabs.
Thank you so much. From you suggest, I did and worked. Here is my ugly sample for someone who need
if [[ -z $CHECK_PROCCESS_GNOME-TERMINAL_EXIST_OR_NOT ]]; then
rm -rf /tmp/1.txt
/usr/bin/gnome-terminal --tab -p -- $1 | tee /tmp/1.txt
else
a=$(egrep SERVICE /tmp/1.txt|cut -d\= -f2)
b=$(egrep SCREEN /tmp/1.txt|cut -d\= -f2)
export GNOME_TERMINAL_SERVICE="$a"
export GNOME_TERMINAL_SCREEN="$b"
/usr/bin/gnome-terminal --title=$SCRIPT_NAME --tab $SCRIPT_NAME -- $1
fi
Tested with gnome-terminal v3.46.8:
gnome-terminal --tab
opens a new tab in an existing gnome-terminal window only, when issued within gnome-terminal. When issuinggnome-terminal --tab
in another application, for example xterm or GNS3, it always opens a new window, never a new tab. There is a hack to open a gnome-terminal tab even when using other programs: When you manage to find out the environment variablesGNOME_TERMINAL_SERVICE
andGNOME_TERMINAL_SCREEN
of a gnome-terminal window and add these to the environment of thegnome-terminal --tab
command, then a new tab in that gnome-terminal window is opened. But I see no easy way to achieve that. The easiest way is to forget about gnome-terminal and use mate-terminal instead. GNS3 already includes the settings for mate-terminal to open new tabs.Thank you so much. From you suggest, I did and worked. Here is my ugly sample for someone who need
if [[ -z $CHECK_PROCCESS_GNOME-TERMINAL_EXIST_OR_NOT ]]; then rm -rf /tmp/1.txt /usr/bin/gnome-terminal --tab -p -- $1 | tee /tmp/1.txt else a=$(egrep SERVICE /tmp/1.txt|cut -d\= -f2) b=$(egrep SCREEN /tmp/1.txt|cut -d\= -f2) export GNOME_TERMINAL_SERVICE="$a" export GNOME_TERMINAL_SCREEN="$b" /usr/bin/gnome-terminal --title=$SCRIPT_NAME --tab $SCRIPT_NAME -- $1 fi
This didn't quite work for me but it inspired the following (mostly AI-generated script) which is working flawless, but many thanks to you for the original idea
#!/bin/bash
INSTANCE_FILE="/tmp/gnome-terminal-${USER}.info"
LOCK_FILE="/tmp/gnome-terminal-${USER}.lock"
SLEEP_TIME=0.15
readonly SERVICE_PATTERN='(?<=SERVICE=).*'
readonly SCREEN_PATTERN='(?<=SCREEN=).*'
focus_terminal() {
type wmctrl >/dev/null 2>&1 && wmctrl -xa "gnome-terminal"
}
check_session_valid() {
local service
service=$(grep -oP "$SERVICE_PATTERN" "$INSTANCE_FILE") || return 1
[[ -n "$service" ]] || return 1
timeout 0.5 gdbus call --session --dest "$service" \
--object-path /org/gnome/Terminal/window/0 \
--method org.freedesktop.DBus.Peer.Ping >/dev/null 2>&1
}
trap 'flock -u 9 2>/dev/null' EXIT
exec 9>"${LOCK_FILE}"
if ! flock -n 9; then
sleep $SLEEP_TIME
if [[ -f "$INSTANCE_FILE" ]] && check_session_valid; then
export GNOME_TERMINAL_SERVICE=$(grep -oP "$SERVICE_PATTERN" "$INSTANCE_FILE")
export GNOME_TERMINAL_SCREEN=$(grep -oP "$SCREEN_PATTERN" "$INSTANCE_FILE")
gnome-terminal --tab
focus_terminal
fi
exit 0
fi
[[ -f "$INSTANCE_FILE" ]] && ! check_session_valid && rm -f "$INSTANCE_FILE"
if [[ -f "$INSTANCE_FILE" ]]; then
GNOME_TERMINAL_SERVICE=$(grep -oP "$SERVICE_PATTERN" "$INSTANCE_FILE")
GNOME_TERMINAL_SCREEN=$(grep -oP "$SCREEN_PATTERN" "$INSTANCE_FILE")
if [[ -n "$GNOME_TERMINAL_SERVICE" ]] && [[ -n "$GNOME_TERMINAL_SCREEN" ]]; then
export GNOME_TERMINAL_SERVICE
export GNOME_TERMINAL_SCREEN
gnome-terminal --tab
focus_terminal
exit 0
fi
fi
gnome-terminal -- bash -c '
echo "SERVICE=$GNOME_TERMINAL_SERVICE" > '"$INSTANCE_FILE"'
echo "SCREEN=$GNOME_TERMINAL_SCREEN" >> '"$INSTANCE_FILE"'
exec $SHELL
'
sleep $SLEEP_TIME
The GNS3 GUI should support opening consoles in tabs. This was implemented in https://github.com/GNS3/gns3-gui/pull/3500
A question, when I open the first terminal I can get gnome-terminal attention but if I open the second there is not windows attention. Is required any configuration?
Does your script get the gnome-terminal window focus when a new tab is opened?
Hum, after having a closer look at your script, indeed it does. Sorry for the question ;)
I noticed the same behavior, the gnome-terminal window is not focused when opening more tabs... from what I read it is the standard behavior on Gnome, I haven't found a work-around.
I have added some improvements and fixed the focus issue described above.
Describe the bug When using gnome-terminal with "--tab" option to open new console sessions in a new tab (default behavior for console profile is new window), a new window is opened instead. When testing from the CLI, opens correctly in new tabs. command string provided below.
gnome-terminal --tab -t "%d" -e "telnet %h %p
GNS3 version and operating system (please complete the following information):
To Reproduce Steps to reproduce the behavior: