xdotool getwindowfocus windowkill currently terminates the active window and bypasses any safeguards like "would you like to save your work?". Is there a weaker command than
windowkill I can here use that won't make such bypasses?
The soft way to request an X11 application to close its window and possibly then exit is to send it a
Xdotool doesn't appear to have a way to do this. You can do it in Perl with X11::Protocol::WM. Untested:
perl -MX11::Protocol -MX11::Protocol::WM -e '$X = X11::Protocol::new(); X11::Protocol::WM::set_wm_protocol($X, ($X->GetInputFocus()), "WM_DELETE_WINDOW")'
wmctrl can do that:
wmctrl -c :ACTIVE: