Created
September 22, 2013 02:11
-
-
Save ajchemist/6656047 to your computer and use it in GitHub Desktop.
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
2 down vote | |
I don't have uptime on my system, so I can't test this for you. But it should give you an idea. Seems to work on my system with ps substituted for uptime. | |
Perhaps someone else will offer a simpler or cleaner solution. You might also look at call-process or start-process instead of shell-command-to-string --- start-process is async. You might also want to consider using an idle timer --- the code here can slow Emacs down considerably, since it calls uptime each time the mode line is updated. | |
(setq-default | |
mode-line-format | |
(list " " 'mode-line-modified | |
"--" 'mode-line-buffer-identification | |
"--" 'mode-line-modes | |
'mode-line-position | |
"--" '(:eval (shell-command-to-string "uptime")) | |
"-%-")) | |
Here is another approach, which doesn't seem to slow things down noticeably: | |
(defun bar () | |
(with-current-buffer (get-buffer-create "foo") | |
(erase-buffer) | |
(start-process "ps-proc" "foo" "uptime"))) | |
(setq foo (run-with-idle-timer 30 'REPEAT 'bar)) | |
(setq-default | |
mode-line-format | |
(list " " 'mode-line-modified | |
"--" 'mode-line-buffer-identification | |
"--" 'mode-line-modes | |
'mode-line-position | |
"--" '(:eval (with-current-buffer (get-buffer-create "foo") | |
(buffer-substring (point-min) (point-max)))) | |
"-%-")) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment