aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2022-09-26 21:26:50 +0200
committerStefan Kangas2022-09-26 21:26:50 +0200
commitbb9df76dc96afa046e8a576708f39881f0535235 (patch)
treeca08b5115fbc8cdfc9dfeae22aec2cdf4f5070a8
parent07e6bbb9bc68f76773e9bdf8846d64d83f50b0ea (diff)
downloademacs-bb9df76dc96afa046e8a576708f39881f0535235.tar.gz
emacs-bb9df76dc96afa046e8a576708f39881f0535235.zip
Set XFCE wallpaper also in single-workspace-mode
This fixes setting the wallpaper on XFCE whether or not the "/backdrop/single-workspace-mode" setting is true or false. That XFCE setting controls whether or not the same wallpaper is used on all workspaces or not. * lisp/image/wallpaper.el (wallpaper-setter) (wallpaper-command-args, wallpaper-default-set-function): Allow using a function for getting the command line arguments. (wallpaper-xfce-command-args): New function. (wallpaper--default-setters): Use above new function for XFCE.
-rw-r--r--lisp/image/wallpaper.el35
1 files changed, 27 insertions, 8 deletions
diff --git a/lisp/image/wallpaper.el b/lisp/image/wallpaper.el
index b2a36e98a44..de650a7318e 100644
--- a/lisp/image/wallpaper.el
+++ b/lisp/image/wallpaper.el
@@ -90,7 +90,7 @@ the image file to set the wallpaper to.")
90 ( name command args-raw 90 ( name command args-raw
91 &rest rest-plist 91 &rest rest-plist
92 &aux 92 &aux
93 (args (if (listp args-raw) 93 (args (if (or (listp args-raw) (symbolp args-raw))
94 args-raw 94 args-raw
95 (string-split args-raw))) 95 (string-split args-raw)))
96 (predicate (plist-get rest-plist :predicate)))) 96 (predicate (plist-get rest-plist :predicate))))
@@ -153,9 +153,7 @@ and returns non-nil if this setter should be used."
153 (member "KDE" (xdg-current-desktop)))) 153 (member "KDE" (xdg-current-desktop))))
154 154
155 ("XFCE" 155 ("XFCE"
156 "xfconf-query" '("-c" "xfce4-desktop" 156 "xfconf-query" #'wallpaper-xfce-command-args
157 "-p" "/backdrop/screen%S/monitor%M/workspace%W/last-image"
158 "-s" "%f")
159 :predicate (lambda () 157 :predicate (lambda ()
160 (or (and (getenv "DESKTOP_SESSION") 158 (or (and (getenv "DESKTOP_SESSION")
161 (member (downcase (getenv "DESKTOP_SESSION")) 159 (member (downcase (getenv "DESKTOP_SESSION"))
@@ -240,6 +238,20 @@ This is used by `wallpaper--find-command' to automatically set
240`wallpaper-command-args'. The setters will be tested in the 238`wallpaper-command-args'. The setters will be tested in the
241order in which they appear.") 239order in which they appear.")
242 240
241(defun wallpaper-xfce-command-args ()
242 (let ((info
243 (with-temp-buffer
244 (call-process "xfconf-query" nil t nil
245 "-c" "xfce4-desktop"
246 "-p" "/backdrop/single-workspace-mode")
247 (buffer-string))))
248 (list "-c" "xfce4-desktop"
249 "-p" (format "/backdrop/screen%%S/monitor%%M/workspace%s/last-image"
250 (if (equal info "true")
251 "0"
252 "%W"))
253 "-s" "%f")))
254
243(defvar wallpaper--current-setter nil) 255(defvar wallpaper--current-setter nil)
244 256
245(defun wallpaper--find-setter () 257(defun wallpaper--find-setter ()
@@ -321,6 +333,9 @@ automatically, so there is usually no need to customize this.
321However, if you do need to change this, you might also want to 333However, if you do need to change this, you might also want to
322customize `wallpaper-command' to match. 334customize `wallpaper-command' to match.
323 335
336The value is a list of command list arguments to use, or a
337function that returns a list of command line arguments.
338
324In each command line argument, these specifiers will be replaced: 339In each command line argument, these specifiers will be replaced:
325 340
326 %f full file name 341 %f full file name
@@ -338,7 +353,8 @@ height and width to use for %h and %w.
338 353
339The value of this variable is ignored on MS-Windows and Haiku 354The value of this variable is ignored on MS-Windows and Haiku
340systems, where a native API is used instead." 355systems, where a native API is used instead."
341 :type '(repeat string) 356 :type '(choice (repeat string)
357 function)
342 :group 'image 358 :group 'image
343 :version "29.1") 359 :version "29.1")
344 360
@@ -424,8 +440,11 @@ FILE is the image file name."
424This is the default function for `wallpaper-set-function'." 440This is the default function for `wallpaper-set-function'."
425 (unless wallpaper-command 441 (unless wallpaper-command
426 (error "Couldn't find a command to set the wallpaper with")) 442 (error "Couldn't find a command to set the wallpaper with"))
427 (let* ((real-args (mapcar (lambda (arg) (wallpaper--format-arg arg file)) 443 (let* ((args (if (functionp wallpaper-command-args)
428 wallpaper-command-args)) 444 (funcall wallpaper-command-args)
445 wallpaper-command-args))
446 (real-args (mapcar (lambda (arg) (wallpaper--format-arg arg file))
447 args))
429 (bufname (format " *wallpaper-%s*" (random))) 448 (bufname (format " *wallpaper-%s*" (random)))
430 (process 449 (process
431 (and wallpaper-command 450 (and wallpaper-command
@@ -434,7 +453,7 @@ This is the default function for `wallpaper-set-function'."
434 (unless wallpaper-command 453 (unless wallpaper-command
435 (error "Couldn't find a suitable command for setting the wallpaper")) 454 (error "Couldn't find a suitable command for setting the wallpaper"))
436 (wallpaper-debug "Using command: \"%s %s\"" 455 (wallpaper-debug "Using command: \"%s %s\""
437 wallpaper-command (string-join wallpaper-command-args " ")) 456 wallpaper-command (string-join args " "))
438 (wallpaper-debug (wallpaper--format-arg 457 (wallpaper-debug (wallpaper--format-arg
439 "f=%f w=%w h=%h S=%S M=%M W=%W" file)) 458 "f=%f w=%w h=%h S=%S M=%M W=%W" file))
440 (setf (process-sentinel process) 459 (setf (process-sentinel process)