desktop-save-hook is a variable defined in `desktop.el'.
Its value is

  • This variable may be risky if used as a file-local variable.

Normal hook run before the desktop is saved in a desktop file.
Run with the desktop buffer current with only the header present.
May be used to add to the desktop code or to truncate history lists,
for example.

You can customize this variable.