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.
Any of the POSIX signals you can send will close the application immediately.
You can use
wmctrl
:Use
-F
to search strictly.Notes
xdottool
wmctrl -l
and then close it withwmctrl -ic ID
.