Skip to content

Instantly share code, notes, and snippets.

@haxcited
Created February 19, 2020 13:53
Show Gist options
  • Save haxcited/20bee1fb1274d629eecb4f6e91035fc6 to your computer and use it in GitHub Desktop.
Save haxcited/20bee1fb1274d629eecb4f6e91035fc6 to your computer and use it in GitHub Desktop.
;; thanks emacsomancer for the config
;; alert
(use-package alert
:ensure t
:config
(require 'alert)
(setq alert-default-style 'libnotify)
(setq alert-fade-time 300)
(setq alert-persist-idle-time 300))
;;; sauron
(use-package sauron
:ensure t
:config
(require 'sauron-org) ; appt alerts (?!)
(setq sauron-modules '(sauron-erc sauron-dbus sauron-org sauron-notifications ; get rid of twittering one
sauron-jabber sauron-identica))
;; allow dbus
(setq sauron-dbus-cookie t)
;; debug
(setq sauron-debug t)
;; note, you add (setq sauron-debug t) to get errors which can debug if
;; there's something wrong; normally, we catch such errors, since e.g an error
;; in one of the hooks may cause ERC to fail (i.e., the message won't come
;; trough).
(setq
sauron-max-line-length 120
;; you probably want to add your own nickname to the these patterns
sauron-watch-patterns
'("emacsomancer")
;; '("emacs-fu" "emacsfu" "wombat" "capybara" "yak" "gnu" "\\bmu\\b")
;; you probably want to add you own nick here as well
sauron-watch-nicks
'("beslayed" "emacsomancer")
;; '("Tom" "Dick" "Harry"))
)
(add-hook 'sauron-event-added-functions #'sauron-alert-el-adapter) ; integrate with alert.el
;; ;; set volume for sox
;; (defun sauron-fx-sox (path)
;; "Play a wav-file at PATH using program sox."
;; (unless (and (file-readable-p path) (file-regular-p path))
;; (error "%s is not a playable file" path))
;; (unless (executable-find "sox")
;; (error "sox not found"))
;; (call-process "sox" nil 0 nil "--volume=1" "-V0" "-q" path "-d"))
;; some sound/light effects for certain events
;; (add-hook 'sauron-event-added-functions
;; (lambda (origin prio msg &optional props)
;; (if (string-match "ping" msg)
;; (sauron-fx-sox (expand-file-name "~/elisp/sounds/kde/KDE-Im-Low-Priority-Message.ogg")))
;; (cond
;; ((= prio 3) )
;; ;; ((= prio 3) (sauron-fx-sox (expand-file-name "~/elisp/sounds/kde/KDE-Im-New-Mail.ogg")))
;; ((= prio 4) (sauron-fx-sox (expand-file-name "~/elisp/sounds/kde/KDE-Im-Nudge.ogg")))
;; ((= prio 5)
;; (sauron-fx-sox (expand-file-name "~/elisp/sounds/kde/KDE-Sys-Question.ogg"))
;; (sauron-fx-gnome-osd(format "%S: %s" origin msg) 5)))))
;; (remove-hook 'after-make-frame-functions '(lambda (sauron-start)) t) ; start sauron with first opened frame
(global-set-key (kbd "\C-c1") 'sauron-start) ;; sauron-start keybind
)
;; this is the old code I have for ercn, though I'm using weechat.el now
;; get channel info etc.
(defun do-notify (nickname message)
(let* ((channel (buffer-name))
;; using https://github.com/leathekd/erc-hl-nicks
(nick (erc-hl-nicks-trim-irc-nick nickname))
(title (if (string-match-p (concat "^" nickname) channel)
nick
(concat nick " (" channel ")"))))
(alert message :title title)
; (shell-command (concat "notify-send -u critical -t 1800000 " " '" title "' '" message "'"))
;; Using https://github.com/magnars/s.el
; (msg (s-trim (s-collapse-whitespace message))))
;; call the system notifier here
))
(add-hook 'ercn-notify-hook #'do-notify)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment