diff options
author | JSDurand <mmemmew@gmail.com> | 2021-01-16 14:04:07 +0800 |
---|---|---|
committer | JSDurand <mmemmew@gmail.com> | 2021-01-16 14:06:06 +0800 |
commit | 96d038c44a1ef26892adf4b775d1e2efe9e7b44b (patch) | |
tree | 559dd92faefcba14bb7b045289017dc34d80c9b5 /view-conf.el | |
parent | 66e440458db37f91903ce8d0c19867f010f7a1a2 (diff) |
The first stable version
Fixes: Avoid adding suffix-link repeatedly
* embark-conf.el ("embark"): Use view-mode instead of view-file
* init.el (load-after-function): Modify the macro so that it no longer
redefines built-in functions.
(global-map):
("view-conf.el"): Rename view-functions.el to view-conf.el
* suffix tree/generalized-suffix-tree.el (gst-edge-length):
(gst-add-suffix-link):
(gst-canonize):
(gst-extend-tree):
(gst-build-for-strs):
Fixed the bug.
* suffix tree/gst debugging platform.txt (strs): Add a new debugging file
* suffix tree/gst test ground (2).txt (strs): Do more debugging
* tab-conf.el (durand-switch-tab-dwim): Add my own dwim tab function.
(global-map): Bind it to the global map.
* theme.el Update the modus-themes.
* view-conf.el Rename view-functions.el to view-conf.el.
Diffstat (limited to 'view-conf.el')
-rw-r--r-- | view-conf.el | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/view-conf.el b/view-conf.el new file mode 100644 index 0000000..ee6b8dd --- /dev/null +++ b/view-conf.el @@ -0,0 +1,96 @@ +;;; view-conf.el --- My configurations to view things -*- lexical-binding: t; -*- + +;;;###autoload +(defun durand-view-timers-or-temps (&optional arg) + "View the list of timers or view the CPU temperature info. +If ARG is nil, view the list of timers. +If ARG is '(4), view the information about CPU temperature and +fans speed and some others. +If ARG is '(16), view the battery information." + (interactive "P") + (cond + ((null arg) + (let (fan-speed + cpu-die-temperature + remain + full-capacity + fullp + charging + cycle + condition + connected + battery-temp) + (with-temp-buffer +;;; NOTE: First fans information + (insert (funcall + (plist-get (car (auth-source-search :host "local-computer")) + :secret))) + (call-process-region + nil nil "sudo" + nil t nil "-S" "powermetrics" + "-i1" "-n1" "-ssmc") + (goto-char (point-min)) + (search-forward "Fan" nil t) + (setf fan-speed + (progn (re-search-forward "[[:digit:]]+" (line-end-position) t) + (string-to-number (match-string 0))) + cpu-die-temperature + (progn (re-search-forward "temperature: \\([[:digit:]]+\\.[[:digit:]]+\\)" nil t) + (string-to-number (match-string 1)))) + +;;; NOTE: Now battery charge information + (erase-buffer) + (call-process "system_profiler" nil t nil + "SPPowerDataType") + (goto-char (point-min)) + (re-search-forward "Fully Charged: \\(.+\\)$" nil t) + (setf fullp (match-string-no-properties 1)) + (re-search-forward "Charging: \\(.+\\)$" nil t) + (setf charging (match-string-no-properties 1)) + (re-search-forward "Full Charge Capacity (mAh): \\([[:digit:]]+\\)$" nil t) + (setf full-capacity (string-to-number (match-string-no-properties 1))) + (re-search-forward "State of Charge (%): \\([[:digit:]]+\\)" nil t) + (setf remain (string-to-number (match-string-no-properties 1))) + (re-search-forward "Cycle Count: \\(.+\\)$" nil t) + (setf cycle (string-to-number (match-string-no-properties 1))) + (re-search-forward "Condition: \\(.+\\)$" nil t) + (setf condition (match-string-no-properties 1)) + (re-search-forward "Connected: \\(.+\\)$" nil t) + (setf connected (match-string-no-properties 1)) + +;;; NOTE: Now battery temperature + (erase-buffer) + (call-process "ioreg" nil t nil "-n" "AppleSmartBattery" "-r") + (goto-char (point-min)) + (re-search-forward "Temperature..=." nil t) + (re-search-forward "[[:digit:]]+" nil t) + (setf battery-temp + (/ (string-to-number (match-string-no-properties 0)) + 100.0))) + (message + (concat + (format "fan: %d, temp: %s, battery temp: %.2f" + fan-speed cpu-die-temperature battery-temp) + "\n" + (format "Full: %d, remaining: %d%s, fullp: %s, charging: %s, connected: %s, cycles: %d, condition: %s" + full-capacity remain "%%" fullp charging connected cycle condition))))) + ((equal arg (list 4)) (list-timers)) + (t + (user-error "Unsupported ARG: %S" arg)))) + +(define-obsolete-function-alias 'durand-view-timers 'durand-view-timers-or-temps + "2020-09-02" "View the list of timers.") + +;;;###autoload +(defun durand-view-process (&optional arg) + "View the list of processes" + (interactive "P") + (if arg + (proced) + (message "%s" (process-list)))) + +;;; About view-mode + +(require 'view) + +(define-key view-mode-map (vector 108) 'recenter-top-bottom) |