Subject: bug#57781: missing wallpaper command

From: Thierry Volpiatto <[email-masked]>
Date: Sat, 17 Sep 2022 06:14:11 +0000

Stefan Kangas <[email-masked]> writes:

> Thierry Volpiatto <[email-masked]> writes:
>
>> Don't know if you already added a command for xfce, if not here is what
>> I use:
>>
>>     (apply #'call-process "xfconf-query" nil nil nil
>>            `("-c"
>>             "xfce4-desktop" "-p"
>>             "/backdrop/screen0/monitoreDP/workspace0/last-image" "-s"
>>             ,file))
>
> I did not yet have the command, so thank you.  I have added this to
> wallpaper.el on master now (commit fe7c015b20 or attached patch).
>
> Do you mind testing to see if it works for you?

The xconf-query command is detected and working fine, thanks.
Perhaps you can store last wallpapers used and use it as default for the
read-file-name?
Something like this:

diff --git a/lisp/image/wallpaper.el b/lisp/image/wallpaper.el
index 4572a8c0628..8426fc4b126 100644
--- a/lisp/image/wallpaper.el
+++ b/lisp/image/wallpaper.el
@@ -227,6 +227,8 @@ See also `wallpaper-default-height'.")
 This is only used when it can't be detected automatically.
 See also `wallpaper-default-width'.")
 
+(defvar wallpaper-last-used nil)
+
 (defun wallpaper--get-height-or-width (desc fun default)
   (if (display-graphic-p)
       (funcall fun)
@@ -246,7 +248,10 @@ 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 (list (read-file-name "Set desktop background to: "
-                                     default-directory nil t nil
+                                     (and wallpaper-last-used
+                                          (file-name-directory
+                                           (car (last wallpaper-last-used))))
+                                     wallpaper-last-used t nil
                                      (lambda (fn)
                                        (or (file-directory-p fn)
                                            (string-match (image-file-name-regexp) fn))))))
@@ -257,6 +262,7 @@ so the value of `wallpaper-commands' is ignored."
   (unless (file-readable-p file)
     (error "File is not readable: %s" file))
   (wallpaper-debug "Using image %S:" file)
+  (push file wallpaper-last-used)
   (cond ((eq system-type 'windows-nt)
          (w32-set-wallpaper file))
         ((featurep 'haiku)

> [2. text/x-diff; 0001-Support-XFCE-in-wallpaper.el.patch]...

-- 
Thierry