[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cpupower db7bf2406c 12/35: a bit more
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cpupower db7bf2406c 12/35: a bit more |
Date: |
Thu, 5 May 2022 15:57:45 -0400 (EDT) |
branch: externals/cpupower
commit db7bf2406c5ed628ea7ec9f5ffe54eb8d301c2a0
Author: smeister <smeister@awstruepower.com>
Commit: smeister <smeister@awstruepower.com>
a bit more
---
cpupower.el | 54 ++++++++++++++++++++++++++++++++++++++----------------
1 file changed, 38 insertions(+), 16 deletions(-)
diff --git a/cpupower.el b/cpupower.el
index 9eef3d41a9..edd5bb4aed 100644
--- a/cpupower.el
+++ b/cpupower.el
@@ -19,7 +19,13 @@
;;; Commentary
;; If you have cpupower installed, this provides a very simple wrapper
-;; to that program.
+;; to that program. You'll need to configure your system such that
+;; the user you're using emacs as can run cpupower (probably as `sudo
+;; cpupower` from a command line). You can configure how cpupower is
+;; called by customizing cpupower-cmd.
+;;
+;; This module interacts with cpupower via running it in a shell.
+;;
;;
;; The commands you'll probably want to use:
;; * cpupower-info
@@ -35,27 +41,32 @@
;; * cpupower-get-current-governors
;; - returns a list of all cpu governors by core.
-
+;;; Code:
;; pretty sure I don't need this, but?
(setq lexical-binding t)
-(defconst cpupower-cmd
+(defcustom cpupower-cmd
"sudo cpupower"
- "cpupower command, might need a 'sudo' infront of it")
+ "cpupower command, might need a 'sudo' infront of it and you
+might need to enable this command for your user in /etc/sudoers"
+ :type '(string)
+ :group 'cpupower)
(defconst cpupower--compatible-versions
'("5.4")
- "Versions of cpupower which cpupower.el can work with")
+ "Versions of cpupower which cpupower.el can work with.")
(defvar cpupower--info
nil
"Where cached information about cpupower will be put")
(defmacro cpupower--with-cache-slot (cache-slot-name deriving-sexp)
- "Get something from cache or derive it and populate cache.
+ "Get something from cache (cpupower--info) or derive it and populate cache.
-This macro isn't strictly needed but I kinda wanted to practice
-writing macros. So here we are."
+CACHE-SLOT-NAME is the key under which the result is stored.
+
+DERIVING-SEXP is a single sexp which should return the value. It
+will be called if the value is not cached."
(declare (indent 1))
`(let ((cached-value (plist-get cpupower--info ,cache-slot-name)))
(if cached-value
@@ -88,7 +99,9 @@ TODO: do this in a less bad way?"
cpu-count)))
(defun cpupower--get-available-governors ()
- "Get a list of all valid governors for this system."
+ "Get a list of all valid governors for this system.
+
+@todo - this should be done using cpupower? not cat-ing some random file."
(cpupower--with-cache-slot :governors
(let ((governors-per-cpu))
(cl-loop for cpu-num in (number-sequence 0 (cpupower--get-num-cpus))
@@ -106,7 +119,7 @@ TODO: do this in a less bad way?"
finally return valid-governors))))
(defun cpupower--run (subcommand)
- "Execute cpupower with SUBCOMMAND string."
+ "Execute cpupower with SUBCOMMAND arguments return the output as a string."
(with-temp-buffer
(let ((command (format "%s %s" cpupower-cmd subcommand)))
(message "running: %s" command)
@@ -114,7 +127,7 @@ TODO: do this in a less bad way?"
(buffer-string))))
(defun cpupower--format-KHz (KHz)
- "Format KHz for human eyes (probably translating to MHz or GHz)."
+ "Format KHZ (as KHz) for human eyes (probably translating to MHz or GHz)."
(cond ((> KHz 1000000)
(format "%.2fGHz" (/ KHz 1000000.0)))
((> KHz 1000)
@@ -149,7 +162,10 @@ function returns: (\"and\" \"too\")
finally return output-tokens))
(defun cpupower-info ()
- "Place current cpupower information into the message buffer."
+ "Place current cpupower information into the message buffer.
+
+This is indented as the primary way for humans to see this
+information."
(interactive)
(let ((governors (seq-uniq (cpupower-get-current-governors) 'string-equal))
(frequencies (mapcar 'cpupower--format-KHz
(cpupower-get-current-frequencies))))
@@ -159,7 +175,7 @@ function returns: (\"and\" \"too\")
(cpupower--get-version))))
(defun cpupower-set-governor (governor)
- "Set the governor on all CPUs to a given governor by name (string)."
+ "Set the governor on all CPUs to a given GOVERNOR by name (string)."
(interactive "sGovernor: ")
(let ((valid-governors (cpupower--get-available-governors)))
(unless (member governor valid-governors)
@@ -168,7 +184,10 @@ function returns: (\"and\" \"too\")
(cpupower-info)))
(defun cpupower-get-current-frequencies (&optional print-message)
- "Return a list of CPU frequencies in KHz"
+ "Return a list of CPU frequencies in KHz
+
+When called interactively (PRINT-MESSAGE will be true) it will
+message the user with current CPU frequencies."
(interactive "p")
(let* ((output (cpupower--run "--cpu all frequency-info -f"))
(frequencies (mapcar 'string-to-number
@@ -179,7 +198,10 @@ function returns: (\"and\" \"too\")
frequencies))
(defun cpupower-get-current-governors (&optional print-message)
- "Return a list of CPU governors"
+ "Return a list of CPU governors
+
+When called interactively (PRINT-MESSAGE will be true) it will
+message the user with current CPU governors"
(interactive "p")
(let* ((output (cpupower--run "--cpu all frequency-info -p"))
(governors (mapcar (lambda (quoted)
@@ -193,7 +215,7 @@ function returns: (\"and\" \"too\")
governors))
(defun cpupower-helm-set-governor ()
- "Set cpu governor using helm
+ "Set cpu governor using helm.
@TODO - this should only exist when helm is installed?"
(interactive)
- [elpa] externals/cpupower 3824c2aae4 25/35: remove that warning?, (continued)
- [elpa] externals/cpupower 3824c2aae4 25/35: remove that warning?, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower c62689f72e 24/35: now without cat-ing random files, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower d2e1eacaba 13/35: ok, that looks reasonable, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 40e5ece723 17/35: Merge branch 'with-readme', ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower f661743bcf 19/35: :shrug:, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 24bd212efe 28/35: ok, got those backwards, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 3b29497bc3 01/35: here's the first piece, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 7b0e057ca6 05/35: ok, I think it works now., ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 4e85b4dc02 04/35: Initial commit, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower d38011bbb9 06/35: Merge branch 'starting' into 'main', ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower db7bf2406c 12/35: a bit more,
ELPA Syncer <=
- [elpa] externals/cpupower 3501256e73 14/35: okay., ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower b661a409c6 16/35: :shrug:, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower fa9888163d 03/35: more?, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 5efe8c1f7d 11/35: clean up pass, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 9f283594a9 20/35: :shrug:, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 40952ede70 32/35: using keyword recommended by the manual, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower a18d913837 29/35: logging control, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower e9127b20a4 21/35: now working with quelpa without warnings, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower 41cd60e2e5 26/35: keywords?, ELPA Syncer, 2022/05/05
- [elpa] externals/cpupower a8da800f6a 18/35: testing?, ELPA Syncer, 2022/05/05