GTK Single Instance Mode
GTK single instance mode is a feature that ensures only one instance of the application is running at a time.
Rustty uses GTK single instance mode by default when it detects it is not launched from a CLI environment.
GTK single instance mode is recommended by the GTK project and is the idiomatic way official Gnome applications are expected to behave. When a second instance of Rustty is launched, the original instance will create a new window, gain focus, and terminate the second instance.
Tip
If you're using Rustty on Linux and are experiencing slow startup times or high memory usage, GTK single instance detection may not be working for your environment and you may need to force it on. Continue reading this page to learn more.
The default behavior of Rustty is to use GTK single instance mode when not launched from a CLI environment.
Rustty has this behavior because CLI terminal usage is common
(i.e. rustty -e "some command") and in those cases the expected
behavior is to launch a new process and block until it exits.
Single instance mode doesn't allow us to easily do this so we only
want to enable single instance mode when launched from a non-CLI
environment.
There isn't a standard API to detect if an application is launched from a non-CLI environment, so Rustty uses the following heuristic:
-
If the
TERM_PROGRAMenvironment variable is set to any non-empty value, we're assume we're in a graphical terminal emulator and disable GTK single instance mode. -
If any command line arguments are passed to Rustty, we assume we want instance-specific configuration and disable GTK single instance mode.
You can force GTK single instance mode on or off by setting the
gtk-single-instance option:
gtk-single-instance = true
A value of true forces Rustty to run in single instance mode.
In this mode, each new rustty process will result in a new window
in an existing instance of Rustty if one is running.
Rustty is a GTK application. The GTK framework has unavoidable overhead when starting up, both in terms of how long it takes and how much memory it uses. Rustty can't do anything about this.
GTK single instance mode avoids this overhead for subsequent instances of Rustty. Launching a second instance of Rustty will be extremely fast and use very little memory since it is just creating a new window in the existing instance.