Subject: Re: bug#57781: missing wallpaper command

From: Thierry Volpiatto <[email-masked]>
Date: Sun, 18 Sep 2022 03:33:09 +0000

Stefan Kangas <[email-masked]> writes:

> Thierry Volpiatto <[email-masked]> writes:
>
>> 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:
>
> Hmm, maybe.  But shouldn't the default rather be something like
> `ffap-file-at-point'?  Or maybe even
>
>     (cons (ffap-file-at-point) wallpaper-last-used)

This assume you have an image at point, if not when cycling with M-n in
defaults the first M-n hit will show a non filename i.e. your current
buffer-file-name.

>> 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)

-- 
Thierry