I have written a short python script that will ensure that you only play a sound when your print ends if it's not within the small hours of the morning.
This might be useful if you happen to have parents or kids who are sleeping while you are printing at night and usually play a sound on completion of a print.
This also serves as a useful guide (the python script that is) to calling a macro in klipper from a python script.
Please see 'call_gcode_macro.py' in this directory.