From 2e0cde244a99b83b221dc5ecce24167bf4bc1a5d Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Thu, 15 Sep 2022 18:27:48 +0200 Subject: [PATCH] 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. --- lisp/image/wallpaper.el | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lisp/image/wallpaper.el b/lisp/image/wallpaper.el index b5ce7355cd0..d024d6238cb 100644 --- a/lisp/image/wallpaper.el +++ b/lisp/image/wallpaper.el @@ -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) -- 2.39.2