How to use the command xkill (with examples)
The command xkill
is used to kill a window interactively in a graphical session. It allows users to easily terminate a window or an application by simply pointing and clicking on it.
Use case 1: Display a cursor to kill a window when pressing the left mouse button
Code:
xkill
Motivation: This use case is useful when there is a particular window or application that is unresponsive or frozen. By executing this command, you can easily kill the window without having to search for the process ID or terminate it through other means.
Explanation: When the xkill
command is executed without any arguments, it will launch a small crosshair cursor on the screen. By pressing the left mouse button while the crosshair is active, the window under the cursor will be terminated. Pressing any other mouse button will cancel the action.
Example Output: When the left mouse button is pressed, the selected window will immediately close.
Use case 2: Display a cursor to select a window to kill by pressing any mouse button
Code:
xkill -button any
Motivation: Sometimes you may want to select a window to kill from multiple open windows without knowing which one specifically needs to be closed. This use case allows you to terminate any window by simply clicking on it.
Explanation: By adding the argument -button any
to the xkill
command, a cursor will be displayed that enables you to select a window to kill. Pressing any mouse button while the cursor is active will terminate the clicked window.
Example Output: When any mouse button is pressed, the selected window will be closed.
Conclusion:
The xkill
command provides a quick and convenient way to terminate unresponsive or unwanted windows in a graphical session. It eliminates the need to identify process IDs or use alternative methods to kill windows or applications. With the ability to interactively select windows to kill, xkill
simplifies the task of managing multiple windows effectively.