Function: wallpaper-set

wallpaper-set is an autoloaded, interactive and byte-compiled function defined in wallpaper.el.gz.

Signature

(wallpaper-set FILE)

Documentation

Set the desktop background to FILE in a graphical environment.

On GNU/Linux and other Unix-like systems, this relies on an external command. Which command to use is automatically detected in most cases, but can be manually customized with the user options wallpaper-command and wallpaper-command-args.

On MS-Windows and Haiku systems, no external command is needed, so the value of wallpaper-commands is ignored.

Probably introduced at or before Emacs version 29.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/image/wallpaper.el.gz
;;;###autoload
(defun wallpaper-set (file)
  "Set the desktop background to FILE in a graphical environment.

On GNU/Linux and other Unix-like systems, this relies on an
external command.  Which command to use is automatically detected
in most cases, but can be manually customized with the user
options `wallpaper-command' and `wallpaper-command-args'.

On MS-Windows and Haiku systems, no external command is needed,
so the value of `wallpaper-commands' is ignored."
  (interactive
   (let ((default (wallpaper--get-default-file)))
     (list (read-file-name (format-prompt "Set desktop background to" default)
                           default-directory default
                           t nil
                           (let ((re (wallpaper--image-file-regexp)))
                             (lambda (file-name)
                               (or (file-directory-p file-name)
                                   (string-match re file-name))))))))
  (when (file-directory-p file)
    (error "Can't set wallpaper to a directory: %s" file))
  (unless (file-exists-p file)
    (error "No such file: %s" file))
  (unless (file-readable-p file)
    (error "File is not readable: %s" file))
  (wallpaper-debug "Using image %S:" file)
  (funcall wallpaper-set-function file))