I use in .emacs:
(defun my-desktop-save ()
(interactive)
;; `desktop-owner' is a new function in Emacs 22.1.50 to check
;; for conflicts between two running Emacs instances.
;; We don't want automatic saving in the second Emacs process.
(if (and (fboundp 'desktop-owner) (eq (desktop-owner) (emacs-pid)))
(desktop-save "~")))
Why did you not use desktop-save-in-desktop-dir?
This was enough for .emacs, but for desktop.el a proper variable
to save the desktop in is surely `desktop-dirname'. Even though
`desktop-save-in-desktop-dir' is a method that does this, I think we
can't use it, because when `desktop-dirname' is nil initially, it asks
in the minibuffer where to save the desktop (by using `call-interactively'),
but this is not a good thing to do in a function called by a timer.