Support macOS in wallpaper.el

* lisp/image/wallpaper.el (wallpaper--default-commands)
(wallpaper-command): Support macOS using "osascript".
(wallpaper-set): Display image name when wallpaper-debug is t.
This commit is contained in:
Stefan Kangas 2022-09-15 18:27:48 +02:00
parent 471414fe6b
commit 2e0cde244a

View file

@ -31,6 +31,10 @@
;; On Haiku, it uses the `haiku-set-wallpaper' function, which does
;; not rely on any external commands.
;;
;; On macOS, the "osascript" command is used. You might need to
;; disable the option "Change picture" in the "Desktop & Screensaver"
;; preferences for this to work (this was seen with macOS 10.13).
;;
;; Finding an external command to use is obviously a bit tricky to get
;; right, as there is no lack of platforms, window managers, desktop
;; environments and tools. However, it should be detected
@ -57,6 +61,8 @@
("gsettings" "set" "org.gnome.desktop.background" "picture-uri" "file://%f")
;; KDE Plasma
("plasma-apply-wallpaperimage" "%f")
;; macOS
("osascript" "-e" "tell application \"Finder\" to set desktop picture to POSIX file \"%f\"")
;; Other / General X
("gm" "display" "-size" "%wx%h" "-window" "root" "%f")
("display" "-resize" "%wx%h" "-window" "root" "%f")
@ -157,7 +163,8 @@ native API will be used instead (see `haiku-set-wallpaper')."
(const :tag "xwallpaper (X Window System)" "xwallpaper")
(const :tag "hsetroot (X Window System)" "hsetroot")
(const :tag "xloadimage (X Window System)" "xloadimage")
(const :tag "xsetbg (X Window System)" "xsetbg"))
(const :tag "xsetbg (X Window System)" "xsetbg")
(const :tag "osascript (macOS)" "osascript"))
(const :tag "Other (specify)" string))
:set #'wallpaper--set-wallpaper-command
:group 'image
@ -241,6 +248,7 @@ On Haiku, no external command is needed, so the value of
(error "No such file: %s" file))
(unless (file-readable-p file)
(error "File is not readable: %s" file))
(wallpaper-debug "Using image %S:" file)
(cond ((eq system-type 'windows-nt)
(w32-set-wallpaper file))
((featurep 'haiku)