From 4d939690a8a727a85e1055d9f3d7f9650bd96e9b Mon Sep 17 00:00:00 2001 From: Muhammad Herdiansyah Date: Sat, 26 Nov 2016 14:43:59 +0700 Subject: [PATCH] CPU: Added cpu_temp support for BSDs --- neofetch | 18 +++++++++++++++++- neofetch.1 | 4 +++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index a935b9e4..350e1aaa 100755 --- a/neofetch +++ b/neofetch @@ -787,6 +787,20 @@ get_cpu() { # Get cpu cores cores="$(sysctl -n hw.ncpu)" + + # Get cpu temp + if [[ "$cpu_temp" == "on" ]]; then + case "$distro" in + "FreeBSD"* | "PacBSD"* | "DragonFly"* | "PCBSD"*) + temp="$(sysctl -n dev.cpu.0.temperature)" + temp="[${temp/C/°C}]" + ;; + "OpenBSD"* | "Bitrig"*) + temp="$(sysctl -n hw.sensors.lm0.temp0)" + temp="[${temp/ degC/°C}]" + ;; + esac + fi ;; "Solaris") @@ -2934,7 +2948,9 @@ usage() { printf "%s" " NOTE: 'physical' doesn't work on BSD. --cpu_speed on/off Hide/Show cpu speed. --cpu_temp on/off Hide/Show cpu temperature. - NOTE This only works on linux. + NOTE: This only works on Linux and BSD. + NOTE: For FreeBSD-based systems, you need to enable coretemp + kernel module. --distro_shorthand on/off Shorten the output of distro (tiny, on, off) NOTE: This option won't work in Windows (Cygwin) --kernel_shorthand on/off Shorten the output of kernel diff --git a/neofetch.1 b/neofetch.1 index 655bc37d..b6c9edb2 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -48,7 +48,9 @@ Hide/Show cpu speed. .B \--cpu_temp 'on/off' Hide/Show cpu temperature. .br -NOTE This only works on linux. +NOTE: This only works on Linux and BSD. +.br +NOTE: For FreeBSD-based systems, you need to enable coretemp kernel module. .TP .B \--distro_shorthand 'on/off' Shorten the output of distro (tiny, on, off)