From 8615f3f253a1bfd329fe3a4025dc94f1c6b88949 Mon Sep 17 00:00:00 2001 From: Sakooooo <78461130+Sakooooo@users.noreply.github.com> Date: Sun, 24 Nov 2024 09:12:29 +0400 Subject: [PATCH] emacs.org: disable elcord if there are no frames --- config/emacs/emacs.org | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/config/emacs/emacs.org b/config/emacs/emacs.org index 60b88fef..a9bcd20a 100644 --- a/config/emacs/emacs.org +++ b/config/emacs/emacs.org @@ -1080,14 +1080,28 @@ the feds are watching #+end_src ** Elcord (Discord rich precense) #+begin_src emacs-lisp - (use-package elcord - :init - (setq elcord-display-buffer-details nil) - (setq elcord-use-major-mode-as-main-icon t) - (setq elcord-quiet t) - (setq elcord-display-elapsed nil) - :config - (elcord-mode)) + (use-package elcord + :init + (setq elcord-display-buffer-details nil) + (setq elcord-use-major-mode-as-main-icon t) + (setq elcord-quiet t) + (setq elcord-display-elapsed nil) + :config + (defun elcord--disable-elcord-if-no-frames (f) + (ignore f) + (when (let ((frames (delete f (visible-frame-list)))) + (or (null frames) + (elcord-mode -1))) + (defun elcord--enable-on-frame-created (f) + (elcord-mode +1)) + (add-hook 'after-make-frame-functions 'elcord--enable-on-frame-created) + (defun sakomacs/elcord-mode-hook () + (if elcord-mode + (add-hook 'delete-frame-functions 'elcord--disable-elcord-if-no-frames) + (remove-hook 'delete-frame-functions 'elcord--disable-elcord-if-no-frames))) + (add-hook 'elcord-mode-hook 'sakomacs/elcord-mode-hook) + + (elcord-mode)) #+end_src ** Telegram does NOT WORK ON WINDOWS