diff --git a/emacs/.emacs.d/init.el b/emacs/.emacs.d/init.el index d04469f..3ae1e5c 100644 --- a/emacs/.emacs.d/init.el +++ b/emacs/.emacs.d/init.el @@ -156,6 +156,25 @@ MODE1 is enabled and vice-versa." (and "MariaDB [" (1+ nonl) "]")) "> "))))) +(defun awesome-send (command) + "Send COMMAND through awesome-client to awesome." + (shell-command (format "echo '%s' | awesome-client" command))) + +(defun awesome-update-mailbox (gnus-group) + "Update mailcount widget for GNUS-GROUP. + +But only if it is a maildir inbox." + (let ((name (and + (string-match "^nnmaildir\\+\\(.*\\):inbox$" gnus-group) + (match-string 1 gnus-group)))) + (when name + (awesome-send (format "mailwidgets.%s:set_mailcount()" name))))) + +(defun awesome-update-current-mailbox () + "Update mailcount widget for current gnus group." + (when (and (boundp 'gnus-newsgroup-name) gnus-newsgroup-name) + (awesome-update-mailbox gnus-newsgroup-name))) + (defun oni:before-save-func () "Function for `before-save-hook'." (if (eq major-mode 'html-mode) @@ -1267,6 +1286,7 @@ from myaethon2.core.decorators import ( (add-hook 'vala-mode-hook #'oni:vala-mode-func) (add-hook 'write-file-hooks 'oni:write-file-func) (add-hook 'yas-global-mode-hook 'oni:yas-minor-mode-func) +(add-hook 'gnus-exit-group-hook 'awesome-update-current-mailbox) (oni:add-function-to-hooks #'flycheck-mode 'perl-mode-hook 'rst-mode-hook 'rust-mode-hook 'sh-mode-hook