Created
October 24, 2018 05:34
-
-
Save TeMPOraL/6290b5be47cb6f37bb1b18c6fd0f6b61 to your computer and use it in GitHub Desktop.
.stumpwmrc - modeline with Dropbox and current org clock task
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defparameter *org-clock-current-task* "[N/A]") | |
(defparameter *dropbox-current-status* "[Dropbox current status here]") | |
;;; (...) | |
(defun current-dropbox () | |
;; TODO colors | |
(first-line-only (run-external-program "dropbox" '("status")))) | |
;;; mode line | |
(setf *mode-line-timeout* 1) | |
(setf *group-format* "%s%n") ;Just status and number - to save space. | |
(setf *screen-mode-line-format* | |
(list "%g|%v | ^1" | |
'(:eval *org-clock-current-task*) | |
"^>" | |
'(:eval *dropbox-current-status*) | |
" ^2" | |
(current-hostname) | |
"^n | " | |
(current-ips) | |
" | " | |
"^B%d^b")) | |
(setf *time-modeline-string* | |
"^b%a %b ^B%e^3 %H:%M:%S^n") | |
;;; Dropbox monitoring. | |
;;; Offloaded from modeline for performance. | |
(defvar *dropbox-monitoring-timer* nil) | |
(defparameter +dropbox-monitoring-interval-seconds+ 2) | |
(unless *dropbox-monitoring-timer* | |
(setf *dropbox-monitoring-timer* (run-with-timer +dropbox-monitoring-interval-seconds+ | |
+dropbox-monitoring-interval-seconds+ | |
(lambda () | |
(setf *dropbox-current-status* (current-dropbox)))))) | |
;;; Org clock fetching | |
(defparameter +org-clock-file-name+ "/home/temporal/.org.clock") | |
(defparameter +org-clock-monitoring-interval-seconds+ 5) | |
(defvar *fs-monitoring-timer* nil) | |
(defun fetch-current-org-clock () | |
(ignore-errors (read-file-into-string +org-clock-file-name+))) | |
(unless *fs-monitoring-timer* | |
(unless (and (boundp 'cl-fsnotify::*inotify*) | |
cl-fsnotify::*inotify*) ; HACK to ensure we don't reopen fsnotify when re-evaluating the config | |
(cl-fsnotify:open-fsnotify)) | |
(cl-fsnotify:add-watch +org-clock-file-name+) | |
(setf *fs-monitoring-timer* (run-with-timer +org-clock-monitoring-interval-seconds+ | |
+org-clock-monitoring-interval-seconds+ | |
(lambda () | |
(when (some (lambda (event) | |
(and (consp event) | |
(stringp (car event)) | |
(string= (car event) +org-clock-file-name+))) | |
(cl-fsnotify:get-events)) | |
(setf *org-clock-current-task* (fetch-current-org-clock))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment