unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / 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; 9+ 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] 9+ messages in thread

end of thread, other threads:[~2021-03-31  6:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <8735wcogti.fsf@gmail.com>
     [not found] ` <YGNq8IGh12I+QL9I@protected.localdomain>
2021-03-31  5:49   ` Control of fan-speed on Lenovo Thinkpads Utkarsh Singh
2021-03-31  6:27     ` Finding simpler better sudo for Emacs Jean Louis
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: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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).