diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/dashboard-config.el | 24 | ||||
| -rw-r--r-- | modules/dirvish-config.el | 27 | ||||
| -rw-r--r-- | modules/font-config.el | 2 | ||||
| -rw-r--r-- | modules/host-environment.el | 11 | ||||
| -rw-r--r-- | modules/music-config.el | 4 | ||||
| -rw-r--r-- | modules/video-audio-recording.el | 97 |
6 files changed, 128 insertions, 37 deletions
diff --git a/modules/dashboard-config.el b/modules/dashboard-config.el index 918acdf2..3333d96d 100644 --- a/modules/dashboard-config.el +++ b/modules/dashboard-config.el @@ -47,6 +47,15 @@ (t (format dashboard-bookmarks-item-format filename path-shorten))) el))) +;; ------------------------- Banner Title Centering Fix ------------------------ +;; The default centering can be off due to font width calculations. +;; This override allows manual adjustment via dashboard-banner-title-offset. + +(defvar dashboard-banner-title-offset 5 + "Offset to adjust banner title centering. +Positive values shift left, negative values shift right. +Adjust this if the title doesn't appear centered under the banner image.") + ;; ----------------------------- Display Dashboard ----------------------------- ;; convenience function to redisplay dashboard and kill all other windows @@ -182,5 +191,20 @@ (define-key dashboard-mode-map (kbd "t") (lambda () (interactive) (vterm))) (define-key dashboard-mode-map (kbd "d") (lambda () (interactive) (dirvish user-home-dir)))) +;; Override banner title centering (must be after dashboard-widgets loads) +(with-eval-after-load 'dashboard-widgets + (defun dashboard-insert-banner-title () + "Insert `dashboard-banner-logo-title' with adjustable centering offset." + (when dashboard-banner-logo-title + (let* ((title dashboard-banner-logo-title) + (start (point))) + (insert (propertize title 'face 'dashboard-banner-logo-title)) + (let* ((end (point)) + (width (string-width title)) + (adjusted-center (+ (/ (float width) 2) dashboard-banner-title-offset)) + (prefix (propertize " " 'display `(space . (:align-to (- center ,adjusted-center)))))) + (add-text-properties start end `(line-prefix ,prefix indent-prefix ,prefix)))) + (insert "\n")))) + (provide 'dashboard-config) ;;; dashboard-config.el ends here. 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) ("<f11>" . 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) ("<left>" . dired-up-directory) ("<right>" . dired-find-file) diff --git a/modules/font-config.el b/modules/font-config.el index ca5481a4..c6422065 100644 --- a/modules/font-config.el +++ b/modules/font-config.el @@ -57,7 +57,7 @@ (default :default-family "BerkeleyMono Nerd Font" :default-weight regular - :default-height 130 + :default-height 140 :fixed-pitch-family nil ;; falls back to :default-family :fixed-pitch-weight nil ;; falls back to :default-weight :fixed-pitch-height 1.0 diff --git a/modules/host-environment.el b/modules/host-environment.el index 3cec5df1..af9248c2 100644 --- a/modules/host-environment.el +++ b/modules/host-environment.el @@ -44,6 +44,17 @@ "Return t if host system is running the X Window System." (string= (window-system) "x")) +(defun env-x11-p () + "Return t if running under X11 (not Wayland)." + (and (eq (window-system) 'x) + (not (getenv "WAYLAND_DISPLAY")))) + +(defun env-wayland-p () + "Return t if running under Wayland. +Checks WAYLAND_DISPLAY env var, which is set by Wayland compositors. +This returns t even if Emacs is running through XWayland." + (and (getenv "WAYLAND_DISPLAY") t)) + (defun env-terminal-p () "Return t if running in a terminal." (not (display-graphic-p))) diff --git a/modules/music-config.el b/modules/music-config.el index f60ff36a..a3960440 100644 --- a/modules/music-config.el +++ b/modules/music-config.el @@ -407,7 +407,9 @@ Dirs added recursively." ((file-directory-p file) (cj/music-add-directory-recursive file)) ((cj/music--valid-file-p file) (emms-add-file file)) (t (message "Skipping non-music file: %s" file)))) - (message "Added %d item(s) to playlist" (length files))))) + (message "Added %d item(s) to playlist" (length files)))) + + (keymap-set dirvish-mode-map "+" #'cj/music-add-dired-selection)) ;;; EMMS setup and keybindings diff --git a/modules/video-audio-recording.el b/modules/video-audio-recording.el index b3151dba..5c257685 100644 --- a/modules/video-audio-recording.el +++ b/modules/video-audio-recording.el @@ -456,40 +456,75 @@ Otherwise use the default location in `audio-recordings-dir'." (make-directory directory t)) (cj/ffmpeg-record-audio location)))) +(defun cj/recording--wayland-p () + "Return non-nil if running under Wayland." + (string= (getenv "XDG_SESSION_TYPE") "wayland")) + +(defun cj/recording--check-wf-recorder () + "Check if wf-recorder is available (needed for Wayland). +Return t if found, nil otherwise." + (if (executable-find "wf-recorder") + t + (user-error "wf-recorder not found. Install with: sudo pacman -S wf-recorder") + nil)) + (defun cj/ffmpeg-record-video (directory) - "Start an ffmpeg video recording. Save output to DIRECTORY." + "Start a video recording. Save output to DIRECTORY. +Uses wf-recorder on Wayland, x11grab on X11." (cj/recording-check-ffmpeg) (unless cj/video-recording-ffmpeg-process - (let* ((devices (cj/recording-get-devices)) - (mic-device (car devices)) - (system-device (cdr devices)) - (location (expand-file-name directory)) - (name (format-time-string "%Y-%m-%d-%H-%M-%S")) - (filename (expand-file-name (concat name ".mkv") location)) - (ffmpeg-command - (format (concat "ffmpeg -framerate 30 -f x11grab -i :0.0+ " - "-f pulse -i %s " - "-ac 1 " - "-f pulse -i %s " - "-ac 2 " - "-filter_complex \"[1:a]volume=%.1f[mic];[2:a]volume=%.1f[sys];[mic][sys]amerge=inputs=2[out]\" " - "-map 0:v -map \"[out]\" " - "%s") - mic-device - system-device - cj/recording-mic-boost - cj/recording-system-volume - filename))) - ;; start the recording - (setq cj/video-recording-ffmpeg-process - (start-process-shell-command "ffmpeg-video-recording" - "*ffmpeg-video-recording*" - ffmpeg-command)) - (set-process-query-on-exit-flag cj/video-recording-ffmpeg-process nil) - (set-process-sentinel cj/video-recording-ffmpeg-process #'cj/recording-process-sentinel) - (force-mode-line-update t) - (message "Started video recording to %s (mic: %.1fx, system: %.1fx)." - filename cj/recording-mic-boost cj/recording-system-volume)))) + (let* ((devices (cj/recording-get-devices)) + (mic-device (car devices)) + (system-device (cdr devices)) + (location (expand-file-name directory)) + (name (format-time-string "%Y-%m-%d-%H-%M-%S")) + (filename (expand-file-name (concat name ".mkv") location)) + (on-wayland (cj/recording--wayland-p)) + (record-command + (if on-wayland + ;; Wayland: wf-recorder pipes H264 video to ffmpeg for audio mixing + ;; wf-recorder outputs matroska container with H264, ffmpeg adds audio + (progn + (cj/recording--check-wf-recorder) + (format (concat "wf-recorder --no-audio -c h264 -f matroska -o - 2>/dev/null | " + "ffmpeg -i pipe:0 " + "-f pulse -i %s " + "-f pulse -i %s " + "-filter_complex \"[1:a]volume=%.1f[mic];[2:a]volume=%.1f[sys];[mic][sys]amerge=inputs=2[out]\" " + "-map 0:v -map \"[out]\" " + "-c:v copy " + "%s") + (shell-quote-argument mic-device) + (shell-quote-argument system-device) + cj/recording-mic-boost + cj/recording-system-volume + (shell-quote-argument filename))) + ;; X11: use x11grab directly + (format (concat "ffmpeg -framerate 30 -f x11grab -i :0.0+ " + "-f pulse -i %s " + "-ac 1 " + "-f pulse -i %s " + "-ac 2 " + "-filter_complex \"[1:a]volume=%.1f[mic];[2:a]volume=%.1f[sys];[mic][sys]amerge=inputs=2[out]\" " + "-map 0:v -map \"[out]\" " + "%s") + mic-device + system-device + cj/recording-mic-boost + cj/recording-system-volume + filename)))) + ;; start the recording + (setq cj/video-recording-ffmpeg-process + (start-process-shell-command "ffmpeg-video-recording" + "*ffmpeg-video-recording*" + record-command)) + (set-process-query-on-exit-flag cj/video-recording-ffmpeg-process nil) + (set-process-sentinel cj/video-recording-ffmpeg-process #'cj/recording-process-sentinel) + (force-mode-line-update t) + (message "Started video recording to %s (%s, mic: %.1fx, system: %.1fx)." + filename + (if on-wayland "Wayland/wf-recorder" "X11") + cj/recording-mic-boost cj/recording-system-volume)))) (defun cj/ffmpeg-record-audio (directory) "Start an ffmpeg audio recording. Save output to DIRECTORY. |
