Fixed notifications on ERC for MacOS

This commit is contained in:
Jaden Provost Maxwell-Comfort 2024-04-13 21:40:47 -07:00
parent 6955248dd0
commit 00859f9a34

View File

@ -433,6 +433,19 @@ Ledger is a Unix program that implements a finance tracking system or /ledger/.
("monthly bal" ,(format "%%(binary) -f %s bal -p 'this month'" ledger-master-file))))) ("monthly bal" ,(format "%%(binary) -f %s bal -p 'this month'" ledger-master-file)))))
#+end_src #+end_src
** Alert
Alert is another library that better implements system notifications through emacs. As I use both MacOS and Linux, notifications don't work out of the box for both systems. Using alert, I can change this by selecting a working notify system for each OS.
#+begin_src emacs-lisp
(use-package alert
:config
(setq alert-default-style
(if (eq system-type 'darwin)
'osx-notifier
'libnotify)))
#+end_src
** MacOS Environment Fix ** MacOS Environment Fix
When using emacs on MacOS, the environment variables are not synced properly and therefore require a separate package to fix this. In this case, this package is the ~exec-path-from-shell~. When using emacs on MacOS, the environment variables are not synced properly and therefore require a separate package to fix this. In this case, this package is the ~exec-path-from-shell~.
@ -502,22 +515,26 @@ ERC is a builtin package that adds IRC chatting functionality to emacs.
(use-package erc (use-package erc
:ensure nil :ensure nil
:defer t :defer t
:custom
(erc-nick "random936")
(erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
"353" "324" "329" "332" "333" "353" "477"))
(erc-autojoin-channels-alist '((".*\.libera\.chat" "#emacs" "#gentoo" "#systemcrafters")))
(erc-fill-column 120)
(erc-fill-function 'erc-fill-static)
(erc-fill-static-center 20)
(erc-kill-buffer-on-part t)
(erc-kill-queries-on-quit t)
(erc-kill-server-buffer-on-quit t)
:config :config
(setq erc-nick "random936" (add-to-list 'erc-modules 'notifications)
erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "353")
erc-autojoin-channels-alist '((".*\.libera\.chat" "#emacs" "#gentoo" "#systemcrafters"))
erc-fill-column 120
erc-fill-function 'erc-fill-static
erc-fill-static-center 20
erc-kill-buffer-on-part t
erc-kill-queries-on-quit t
erc-kill-server-buffer-on-quit t)
;; Fix for perspective.el not adding ERC buffers to active perspective. ;; Fix for perspective.el not adding ERC buffers to active perspective.
(add-hook 'erc-join-hook (lambda (&rest args) (add-hook 'erc-join-hook (lambda (&rest args)
(persp-add-buffer (current-buffer))))) (persp-add-buffer (current-buffer)))))
#+end_src #+end_src
*** ERC Extensions
To highlight each nickname with a different color, I can use the ~erc-hl-nicks~ package. I can also use the ~erc-image~ package to render images sent by other users over IRC. To highlight each nickname with a different color, I can use the ~erc-hl-nicks~ package. I can also use the ~erc-image~ package to render images sent by other users over IRC.
#+begin_src emacs-lisp #+begin_src emacs-lisp
@ -532,6 +549,17 @@ To highlight each nickname with a different color, I can use the ~erc-hl-nicks~
(add-to-list 'erc-modules 'image)) (add-to-list 'erc-modules 'image))
#+end_src #+end_src
*** ERC Alert Integration
Alert is a notification system that works with MacOS, however it is not integrated by default. To fix this, you need to create a function to hook with the ERC text matching.
#+begin_src emacs-lisp
(defun jm/erc-alert-integration (match-type nick message)
(alert message :title (format "%s in %s" nick (buffer-name)) :category 'erc))
(add-hook 'erc-text-matched-hook 'jm/erc-alert-integration)
#+end_src
* Import Other Files * Import Other Files
This is the section to include imports from other files. This is the section to include imports from other files.