Skip to Content

Solved: How to Stop GNOME Console from Asking to Close Window

Learn how to disable the annoying prompt that appears when you try to close a GNOME Console window with a running process. This article will show you how to do it with a simple command.

Introduction

If you have a process running in the background, such as a watch command, and you try to close the window, you will see a prompt like this:

Solved: How to Stop GNOME Console from Asking to Close Window

Close Window?
Some commands are stll running, closing this window will kill them and may lead to unexpected outcomes.

This prompt is meant to warn you that closing the window will terminate the running process. However, sometimes this prompt is misleading or unnecessary. For example, if you have disowned the process, it will not be affected by closing the window. Or, if you just want to quickly close the window without caring about the process, this prompt will slow you down.

In this article, we will show you how to disable this prompt and close the GNOME Console window without any confirmation. We will also explain why this prompt appears and how to enable it again if you change your mind.

Why Does GNOME Console Ask to Close Window?

GNOME Console is based on VTE, a library that provides terminal emulation and pty management. VTE has a feature called “safe exit”, which checks if there are any child processes running in the terminal before closing it. If there are, it will send a SIGHUP signal to them, which usually causes them to terminate. To prevent accidental data loss or unwanted termination, VTE will show a confirmation dialog before sending the SIGHUP signal.

However, this feature has some limitations and drawbacks. First, it only checks for direct child processes, not grandchild processes or processes that have been disowned. This means that some processes may survive the SIGHUP signal and continue running in the background, while others may be killed without warning. Second, it does not take into account the nature or state of the process. For example, a watch command that simply monitors a directory may not be important enough to warrant a confirmation, while a long-running script that performs a critical task may be too risky to terminate without saving. Third, it adds an extra step and a delay to closing the window, which can be annoying or frustrating for some users.

How to Disable the Close Window Prompt

If you want to disable the close window prompt and close the GNOME Console window without any confirmation, you can use a simple command to change a GSettings key. GSettings is a system for storing and managing application settings in GNOME. It uses a hierarchical structure of schemas, keys, and values to store the settings. You can use the gsettings command-line tool to get or set the values of the keys.

The key that controls the close window prompt is org.gnome.desktop.lockdown.disable-command-line. This key is part of the org.gnome.desktop.lockdown schema, which contains settings for locking down user interface elements. The disable-command-line key prevents the user from accessing the terminal or specifying a command line to be executed (the Alt + F2 command prompt). By setting this key to true, you will also disable the close window prompt in GNOME Console.

1. To set the key to true, open a GNOME Console window and run the following command:

gsettings set org.gnome.desktop.lockdown disable-command-line true

2. You will not see any output or confirmation, but the key will be changed. To verify that the key has been changed, you can run the following command:

gsettings get org.gnome.desktop.lockdown disable-command-line

3. You should see the output:

true

Now, if you try to close the GNOME Console window with a running process, you will not see any prompt and the window will close immediately. The process will receive a SIGHUP signal and may terminate or continue running depending on how it handles the signal.

How to Enable the Close Window Prompt Again

If you want to enable the close window prompt again and restore the default behavior, you can use the same command to set the key to false.

1. Open a GNOME Console window and run the following command:

gsettings set org.gnome.desktop.lockdown disable-command-line false

2. Again, you will not see any output or confirmation, but the key will be changed. To verify that the key has been changed, you can run the following command:

gsettings get org.gnome.desktop.lockdown disable-command-line

3. You should see the output:

false

Now, if you try to close the GNOME Console window with a running process, you will see the prompt again and you will have to confirm or cancel the action.

Frequently Asked Questions (FAQs)

Question: What is the difference between GNOME Console and GNOME Terminal?

Answer: GNOME Console and GNOME Terminal are both terminal emulators for GNOME desktop environment, but they have some differences. GNOME Console is a lightweight and simple terminal that has minimal features and options. It is designed to be fast and easy to use. GNOME Terminal is a more advanced and customizable terminal that has many features and options. It is designed to be powerful and flexible. You can choose which terminal to use based on your preferences and needs.

Question: How can I close the GNOME Console window without terminating the running process?

Answer: If you want to close the GNOME Console window but keep the running process alive, you can use the disown command to detach the process from the terminal. The disown command removes a job from the shell’s job table, which means that the shell will not send a SIGHUP signal to the process when the terminal closes. To use the disown command, you need to run the process in the background with the & operator, and then run the disown command with the job number or the process ID. For example, if you want to run the watch command in the background and disown it, you can run the following commands:

watch ls /tmp &
disown %1

The first command runs the watch command in the background and prints the job number and the process ID. The second command disowns the job with the number 1. You can also use the process ID instead of the job number. After disowning the process, you can close the GNOME Console window without any prompt and the process will continue running in the background.

Question: How can I kill a process that is running in the background after closing the GNOME Console window?

Answer: If you have closed the GNOME Console window with a running process that has been disowned or survived the SIGHUP signal, you can still kill the process by using the kill command. The kill command sends a signal to a process to terminate it. To use the kill command, you need to know the process ID of the process. You can use the ps command to list the processes and find the process ID. For example, if you want to find the process ID of the watch command, you can run the following command:

ps -ef | grep watch

The output will show the process ID in the second column. You can then use the kill command with the process ID to terminate the process. For example, if the process ID is 1234, you can run the following command:

kill 1234

The process will receive a SIGTERM signal and terminate. You can also use other signals to kill the process, such as SIGKILL, which is more forceful and cannot be ignored by the process. To use a different signal, you can use the -s option with the kill command and specify the signal name or number. For example, to use the SIGKILL signal, you can run the following command:

kill -s SIGKILL 1234

Or:

kill -s 9 1234

Summary

In this article, we have learned how to disable and enable the close window prompt in GNOME Console. We have also explained why this prompt appears and how to deal with the running processes in the terminal. We hope that this article has helped you to customize your GNOME Console experience and improve your productivity.

Disclaimer: This article is for informational purposes only and does not constitute professional advice. The author and the publisher are not liable for any damages or losses that may result from the use of the information or commands in this article. Always backup your data and test the commands before applying them to your system.