From 1173330b91e50212828b437fb0be44a80883f686 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 1 Feb 2026 02:00:39 -0600 Subject: feat(dirvish): add wallpaper setter with X11/Wayland support cj/set-wallpaper uses feh on X11, swww on Wayland. Replaces nitrogen-based lambda with proper function. --- modules/dirvish-config.el | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'modules/dirvish-config.el') diff --git a/modules/dirvish-config.el b/modules/dirvish-config.el index 32331821..eb395eb7 100644 --- a/modules/dirvish-config.el +++ b/modules/dirvish-config.el @@ -25,6 +25,7 @@ (eval-when-compile (require 'user-constants)) (eval-when-compile (require 'system-utils)) +(require 'host-environment) ;; mark files in dirvish, attach in mu4e (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode) @@ -210,6 +211,27 @@ regardless of what file or subdirectory the point is on." (shell-quote-argument current-dir))))))) (message "Could not determine current directory.")))) +(defun cj/set-wallpaper () + "Set the image at point as the desktop wallpaper. +Uses feh on X11, swww on Wayland." + (interactive) + (let ((file (expand-file-name (dired-file-name-at-point)))) + (cond + ((env-x11-p) + (if (executable-find "feh") + (progn + (call-process "feh" nil 0 nil "--bg-fill" file) + (message "Wallpaper set: %s (feh)" (file-name-nondirectory file))) + (message "feh not found"))) + ((env-wayland-p) + (if (executable-find "swww") + (progn + (call-process "swww" nil 0 nil "img" file) + (message "Wallpaper set: %s (swww)" (file-name-nondirectory file))) + (message "swww not found"))) + (t + (message "Unknown display server (not X11 or Wayland)"))))) + ;;; ---------------------------------- Dirvish ---------------------------------- (use-package dirvish @@ -307,10 +329,7 @@ regardless of what file or subdirectory the point is on." ("C-x D" . dirvish) ("" . dirvish-side) :map dirvish-mode-map - ("bg" . (lambda () (interactive) - (shell-command - (concat "nitrogen --save --set-zoom-fill " - (dired-file-name-at-point) " >>/dev/null 2>&1")))) + ("bg" . cj/set-wallpaper) ("/" . dirvish-narrow) ("" . dired-up-directory) ("" . dired-find-file) -- cgit v1.2.3