3

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.

2 Answers 2

4

You could use xkill, xdotool or wmctl.

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

5
  • I suggest you explain how to achieve the goal with these tools.
    – guntbert
    May 14, 2015 at 18:46
  • type xkill on the terminal and then click on the window you want to close.
    – VaTo
    May 14, 2015 at 21:04
  • You should put this explanation into your answer.
    – guntbert
    May 14, 2015 at 21:06
  • Based on this, I found xdotool meets my needs: `xdotool search "$FILENAME" windowactivate --sync key --window 0 --clearmodifiers alt+F4. May 14, 2015 at 22:57
  • xkill will kill the process (not just close the program). Feb 14, 2018 at 9:51
0

xkill works if you actually want to kill the application, but if you only want to close the window, xdo or xdotool are better.

My use case is to close/show Transmission's window. Transmission runs a daemon, and xkill also kills the daemon. But I only want to close the window, not kill the entire application.

xdotool has a windowclose action, which could be used with something like:
xdotool search "Transmission" windowclose

However, this doesn't work for some reason. Both xdotool and xdo find multiple windows for "Transmission" (same amount whether a window is shown or not), maybe that's causing issues for xdotool.

But xdo worked for me:
xdo close -a "Transmission"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.