ThePullinger · 2022-11-21 18:16
Just what it says in the title. Is there a package or script I can add to my config that will show me my cpu temperature in the modeline?
edit: for clarification I am using Arch Linux
EricIO · 2022-11-21 19:59
Maybe you could use https://codeberg.org/emacs-weirdware/lemon to code something up.
luiggi_oasis · 2022-11-21 20:02
It might be worth editing the question to clarify what OS you're running. For example, on Linux sensors will write their value into a "file", so I'd expect that you would just need to read the corresponding file at a given interval and print it in the modeline.
ThePullinger · 2022-11-21 20:45
Oh yeah, that would be a good idea wouldn't, sorry i forgot XD. I'm using arch linux
ieure · 2022-11-21 20:45
Lemon has [a Linux temperature monitor](https://codeberg.org/emacs-weirdware/lemon/src/branch/main/lemon-temp.el), but lemon puts everything in the echo area, not the modeline.
I experimented with putting stuff in the modeline, but I dislike how it ends up showing for every window in a frame.
(I am the maintainer of lemon)
42ndohnonotagain · 2022-11-21 21:41
You forgot the «, BTW»!
Sorry, just kidding ;)
tmp3141 · 2022-11-21 22:31
Here's a function I put together to learn about the modeline. Note that it is specific to Linux as far as getting the CPU temperature. See the comment to adjust the path to the actual sensor you want to read on your system. Call this function from your init.el or interactively. It does not check if it's already been added, so multiple calls will get multiple values in the modeline.
(defun mg/add-cpu-temp-modeline ()
"Add CPU temperature to the modeline (Linux-only)"
(interactive)
(defun mg/read-cpu-temp ()
(with-temp-buffer
;; adjust the path below to match the thermal zone you want displayed
;; cat /sys/class/thermal/thermal_zone*/type and look for x86_pkg_temp
;; this is linux distro and CPU dependent
(insert-file-contents "/sys/class/thermal/thermal_zone13/temp")
(format "%.1f°C" (/ (string-to-number (buffer-string)) 1000.0))))
(setq global-mode-string (append global-mode-string '((t (:eval (mg/read-cpu-temp)))))))
7890yuiop · 2022-11-21 22:36
You can put any information in the mode line, if you *have* that information.
What is a command (which can be external to Emacs) for obtaining your CPU temperature?
ThanosRR · 2022-11-22 12:59
I’m using Arch Linux too btw 🫡🙏🏻
ThanosRR · 2022-11-22 13:06
Not sure, but my first thought was to use psutil Python module, then write a function that calls it and displays the value
jsled · 2022-11-23 00:29
> It might be worth editing the question to clarify what OS you're running.
It really does not matter?
"can I put {a value I can obtain in maybe a platform specific way} into the modeline" is not really a platform-specific question.