Closing a GUI window from the command line

6,740

You could use xkill, xdotool or wmctl.

type xkill on the terminal and then click on the window you want to close.

Share:
6,740
Jon G - Megaphone Tech
Author by

Jon G - Megaphone Tech

President of Megaphone Technology Consulting (https://megaphonetech.com). If you need to reach me, I'm "junglebird" on https://chat.civicrm.org.

Updated on September 18, 2022

Comments

  • Jon G - Megaphone Tech
    Jon G - Megaphone Tech over 1 year

    I often run scripts to transform a CSV file which I then preview in LibreOffice. I often open the CSV with xdg-open file.csv. However, if I run that command when the file is already open, LibreOffice simply focuses that window - it doesn't reload the file from disk.

    Is there a way, from the command line, that I can specify a window to close in the GUI? I can't just kill the process, since LibreOffice shares a single pid for all its windows. I'm running the latest version of Cinnamon on Mint 17.1.

  • VaTo
    VaTo about 9 years
    type xkill on the terminal and then click on the window you want to close.
  • guntbert
    guntbert about 9 years
    You should put this explanation into your answer.
  • Jon G - Megaphone Tech
    Jon G - Megaphone Tech about 9 years
    Based on this, I found xdotool meets my needs: `xdotool search "$FILENAME" windowactivate --sync key --window 0 --clearmodifiers alt+F4.
  • Brōtsyorfuzthrāx
    Brōtsyorfuzthrāx over 6 years
    xkill will kill the process (not just close the program).