3
ps aux | grep -i office | awk {'print $2'} | xargs kill 

I can use the above command to kill LibreOffice but it will abruptly kill the process. But I wish to do it the same way it happens when I shut down the system. So it asks me if I wish to save any changes before closing the dialogue box.

Edit: I am building a tool in which I need to kill other processes running. So I wanted to know how to give a chance of closing gracefully to these applications.

Pablo Bianchi
  • 17,371
Shray
  • 391

1 Answers1

1

Any of the POSIX signals you can send will close the application immediately.

You can use wmctrl:

wmctrl -c LibreOffice

Use -F to search strictly.

Notes

  • Very similar to How can I kill a specific X window
  • You can also try with xdottool
  • To kill a specific window you can list them wmctrl -l and then close it with wmctrl -ic ID.
  • Warn: If the process is stuck it may not notice that you closed the window. The window will be gone, but the process will still be there and possibly consume CPU and RAM.
Pablo Bianchi
  • 17,371