all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Control of fan-speed on Lenovo Thinkpads
@ 2021-03-29 20:36 Jean Louis
  2021-03-30  8:12 ` Michael Albinus
  0 siblings, 1 reply; 21+ messages in thread
From: Jean Louis @ 2021-03-29 20:36 UTC (permalink / raw)
  To: Help GNU Emacs

Here is how I control Lenovo Thinkpad T410 (and others) fan speed. I
remember controlling it on different notebooks, I just forgot
which. You may find that you need to change variable
`my-fan-proc-file' to something else. Most of people do not need this,
it will be automatically controlled. But I need it sometimes to cool
down my fan and my palms.

(defun sudo (arguments)
  "Executes list ARGUMENTS with system command `sudo'."
  (let* ((command (format "sudo su -c -- root -c \"%s\"" (string-join (list arguments))))
	 (return (shell-command-to-string command)))
    return))

(defvar my-fan-proc-file "/proc/acpi/ibm/fan")

(defun fan-speed (arg)
  "Controls fan speed provided user has superuser rights and system
command `sudo' works without password. Function will mostly work
on Lenovo Thinkpad notebooks. Prefix argument ARG shall be
numbers from 1 to 9. Numbers from 1 to 7 determine the fan speed
level, number 8 represents auto fan speed level and number 9
represents full fan speed. Activate with `C-u NUMBER M-x
fan-speed'. If invoked without arguments it will show the
contents of the fan control file."
  (interactive "P")
  (when (and (file-exists-p my-fan-proc-file)
	     (rcd-which "sudo"))
    (if arg
	(cond ((= arg 7) (sudo (format "echo level %s >> %s" arg my-fan-proc-file)))
	      ((= arg 8) (sudo (format "echo level auto >> %s" my-fan-proc-file)))
	      ((= arg 9) (sudo (format "echo level full-speed >> %s" my-fan-proc-file)))
	      ((and (< arg 7) (> arg 0)) (if (y-or-n-p (format "Really set fan speed to %s?" arg))
					     (sudo (format "echo level %s >> %s" 7 my-fan-proc-file))))
	      (t (message "Supply better numeric argument to this function from 1 to 9.")))
      (message (file-to-string my-fan-proc-file)))))

Thanks,
Jean Louis

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns




^ permalink raw reply	[flat|nested] 21+ messages in thread
[parent not found: <8735wcogti.fsf@gmail.com>]

end of thread, other threads:[~2021-04-01  9:46 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-29 20:36 Control of fan-speed on Lenovo Thinkpads Jean Louis
2021-03-30  8:12 ` Michael Albinus
2021-03-30  9:42   ` Jean Louis
2021-03-30  9:44   ` Jean Louis
2021-03-30 10:13     ` Michael Albinus
2021-03-30 10:23       ` Finding simpler better sudo for Emacs Jean Louis
2021-03-30 10:34         ` Michael Albinus
2021-03-30 10:43           ` Jean Louis
2021-03-30 10:52             ` Michael Albinus
2021-03-30 11:05               ` Jean Louis
2021-03-30 11:13                 ` Michael Albinus
2021-03-30 11:40                   ` Jean Louis
2021-03-30 15:01   ` Control of fan-speed on Lenovo Thinkpads Stefan Monnier
2021-03-30 20:06     ` Jean Louis
2021-03-31  1:23       ` Stefan Monnier
2021-03-31  5:35         ` Jean Louis
2021-03-31 14:23           ` Stefan Monnier
2021-03-31 20:02             ` Jean Louis
2021-03-31 20:19               ` Stefan Monnier
2021-04-01  9:46                 ` Jean Louis
     [not found] <8735wcogti.fsf@gmail.com>
     [not found] ` <YGNq8IGh12I+QL9I@protected.localdomain>
2021-03-31  5:49   ` Utkarsh Singh
2021-03-31  6:27     ` Finding simpler better sudo for Emacs Jean Louis

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.