Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
neofetch
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
neofetch
Commits
2433b79d
Commit
2433b79d
authored
Dec 14, 2016
by
Dylan Araps
Committed by
GitHub
Dec 14, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #527 from dylanaraps/cpu_fix
CPU: Function cleanup
parents
fb537518
4413c0f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
57 deletions
+51
-57
config
config/config
+4
-3
neofetch
neofetch
+47
-54
No files found.
config/config
View file @
2433b79d
...
@@ -134,11 +134,12 @@ shell_version="on"
...
@@ -134,11 +134,12 @@ shell_version="on"
# CPU speed type
# CPU speed type
#
#
# Default: 'bios'
# Default: 'bios
_limit
'
# Values:
'current', 'min', 'max', 'bios',
# Values:
'scaling_cur_freq', 'scaling_min_freq', 'scaling_max_freq', 'bios_limit'.
# Flag: --speed_type
# Flag: --speed_type
# Supports: Linux with 'cpufreq'
# Supports: Linux with 'cpufreq'
speed_type
=
"bios"
# NOTE: Any file in '/sys/devices/system/cpu/cpu0/cpufreq' can be used as a value.
speed_type
=
"bios_limit"
# Shorten the output of the CPU function
# Shorten the output of the CPU function
#
#
...
...
neofetch
View file @
2433b79d
...
@@ -723,34 +723,25 @@ get_cpu() {
...
@@ -723,34 +723,25 @@ get_cpu() {
# NetBSD emulates the linux /proc filesystem instead of using sysctl for hw
# NetBSD emulates the linux /proc filesystem instead of using sysctl for hw
# information so we have to use this block below which temporarily sets the
# information so we have to use this block below which temporarily sets the
# OS to
'Linux'
for the duration of this function.
# OS to
'Linux'
for the duration of this function.
case
"
$distro
"
in
[[
"
$distro
"
==
"NetBSD"
* ]] && local os=
"Linux"
"NetBSD"
*) local os=
"Linux"
;;
esac
case
"
$os
"
in
case
"
$os
"
in
"Linux"
|
"Windows"
)
"Linux"
|
"Windows"
)
# Get
cpu
name
# Get
CPU
name
case
"
$distro
"
in
case
"
$distro
"
in
"Android"
*) cpu=
"
$(
getprop ro.product.board
)
"
;;
"Android"
*) cpu=
"
$(
getprop ro.product.board
)
"
;;
*) cpu=
"
$(
awk
-F
': | @'
'/model name|Processor/ {printf $2; exit}'
/proc/cpuinfo
)
"
;;
*) cpu=
"
$(
awk
-F
': | @'
'/model name|Processor/ {printf $2; exit}'
/proc/cpuinfo
)
"
;;
esac
esac
speed_dir=
"/sys/devices/system/cpu/cpu0/cpufreq"
speed_dir=
"/sys/devices/system/cpu/cpu0/cpufreq"
temp_dir=
"/sys/class/hwmon/hwmon0/temp1_input"
temp_dir=
"/sys/class/hwmon/hwmon0/temp1_input"
# Get
cpu
speed
# Get
CPU
speed
if [[ -d
"
$speed_dir
"
]]; then
if [[ -d
"
$speed_dir
"
]]; then
case
"
$speed_type
"
in
# Fallback to bios_limit if
$speed_type
fails.
"current"
) speed_type=
"scaling_cur_freq"
;;
"min"
) speed_type=
"scaling_min_freq"
;;
"max"
) speed_type=
"scaling_max_freq"
;;
"bios"
) speed_type=
"bios_limit"
;;
esac
# Fallback to cpuinfo_max_freq if
$speed_type
fails
speed=
"
$(
<
"
${
speed_dir
}
/
${
speed_type
}
"
)
"
|| \
speed=
"
$(
<
"
${
speed_dir
}
/
${
speed_type
}
"
)
"
|| \
speed=
"
$(
<
"
${
speed_dir
}
/bios_limit"
)
"
|| \
speed=
"
$(
<
"
${
speed_dir
}
/bios_limit"
)
"
|| \
speed=
"
$(
<
"
${
speed_dir
}
/scaling_max_freq"
)
"
speed=
"
$(
<
"
${
speed_dir
}
/scaling_max_freq"
)
"
speed=
"
$((
speed
/
100000
))
"
speed=
"
$((
speed
/
100000
))
"
else
else
...
@@ -758,14 +749,14 @@ get_cpu() {
...
@@ -758,14 +749,14 @@ get_cpu() {
speed=
"
$((
speed
/
100
))
"
speed=
"
$((
speed
/
100
))
"
fi
fi
# Get
cpu
temp
# Get
CPU
temp
if [[
"
$cpu_temp
"
==
"on"
&& -f
"
$temp_dir
"
]]; then
if [[
"
$cpu_temp
"
==
"on"
&& -f
"
$temp_dir
"
]]; then
temp=
"
$(
<
"
$temp_dir
"
)
"
temp=
"
$(
<
"
$temp_dir
"
)
"
temp=
"
$((
temp
*
100
/
10000
))
"
temp=
"
$((
temp
*
100
/
10000
))
"
temp=
"[
${
temp
/
${
temp
:
-1
}}
.
${
temp
:
-1
}
°C]"
temp=
"[
${
temp
/
${
temp
:
-1
}}
.
${
temp
:
-1
}
°C]"
fi
fi
#
Show/hide hyperthreaded
cores
#
Get CPU
cores
case
"
$cpu_cores
"
in
case
"
$cpu_cores
"
in
"logical"
|
"on"
) cores=
"
$(
grep
-c
"^processor"
/proc/cpuinfo
)
"
;;
"logical"
|
"on"
) cores=
"
$(
grep
-c
"^processor"
/proc/cpuinfo
)
"
;;
"physical"
) cores=
"
$(
grep
"^core id"
/proc/cpuinfo |
sort
-u
|
wc
-l
)
"
;;
"physical"
) cores=
"
$(
grep
"^core id"
/proc/cpuinfo |
sort
-u
|
wc
-l
)
"
;;
...
@@ -775,7 +766,7 @@ get_cpu() {
...
@@ -775,7 +766,7 @@ get_cpu() {
"Mac OS X"
)
"Mac OS X"
)
cpu=
"
$(
sysctl
-n
machdep.cpu.brand_string
)
"
cpu=
"
$(
sysctl
-n
machdep.cpu.brand_string
)
"
#
Show/hide hyperthreaded
cores
#
Get CPU
cores
case
"
$cpu_cores
"
in
case
"
$cpu_cores
"
in
"logical"
|
"on"
) cores=
"
$(
sysctl
-n
hw.logicalcpu_max
)
"
;;
"logical"
|
"on"
) cores=
"
$(
sysctl
-n
hw.logicalcpu_max
)
"
;;
"physical"
) cores=
"
$(
sysctl
-n
hw.physicalcpu_max
)
"
;;
"physical"
) cores=
"
$(
sysctl
-n
hw.physicalcpu_max
)
"
;;
...
@@ -810,20 +801,20 @@ get_cpu() {
...
@@ -810,20 +801,20 @@ get_cpu() {
;;
;;
"BSD"
)
"BSD"
)
# Get
cpu
name
# Get
CPU
name
cpu=
"
$(
sysctl
-n
hw.model
)
"
cpu=
"
$(
sysctl
-n
hw.model
)
"
cpu=
"
${
cpu
/[0-9]\.*
}
"
cpu=
"
${
cpu
/[0-9]\.*
}
"
cpu=
"
${
cpu
/ @*
}
"
cpu=
"
${
cpu
/ @*
}
"
# Get
cpu
speed
# Get
CPU
speed
speed=
"
$(
sysctl
-n
hw.cpuspeed
)
"
speed=
"
$(
sysctl
-n
hw.cpuspeed
)
"
[[ -z
"
$speed
"
]] && speed=
"
$(
sysctl
-n
hw.clockrate
)
"
[[ -z
"
$speed
"
]] && speed=
"
$(
sysctl
-n
hw.clockrate
)
"
speed=
"
$((
speed
/
100
))
"
speed=
"
$((
speed
/
100
))
"
# Get
cpu
cores
# Get
CPU
cores
cores=
"
$(
sysctl
-n
hw.ncpu
)
"
cores=
"
$(
sysctl
-n
hw.ncpu
)
"
# Get
cpu
temp
# Get
CPU
temp
if [[
"
$cpu_temp
"
==
"on"
]]; then
if [[
"
$cpu_temp
"
==
"on"
]]; then
case
"
$kernel_name
"
in
case
"
$kernel_name
"
in
"FreeBSD"
* |
"DragonFly"
*)
"FreeBSD"
* |
"DragonFly"
*)
...
@@ -839,17 +830,17 @@ get_cpu() {
...
@@ -839,17 +830,17 @@ get_cpu() {
;;
;;
"Solaris"
)
"Solaris"
)
# Get
cpu
name
# Get
CPU
name
cpu=
"
$(
psrinfo
-pv
)
"
cpu=
"
$(
psrinfo
-pv
)
"
cpu=
"
${
cpu
//*
$'
\n
'
}
"
cpu=
"
${
cpu
//*
$'
\n
'
}
"
cpu=
"
${
cpu
/[0-9]\.*
}
"
cpu=
"
${
cpu
/[0-9]\.*
}
"
cpu=
"
${
cpu
/ @*
}
"
cpu=
"
${
cpu
/ @*
}
"
# Get
cpu
speed
# Get
CPU
speed
speed=
"
$(
psrinfo
-v
|
awk
'/operates at/ {print $6; exit}'
)
"
speed=
"
$(
psrinfo
-v
|
awk
'/operates at/ {print $6; exit}'
)
"
speed=
"
$((
speed
/
100
))
"
speed=
"
$((
speed
/
100
))
"
#
Show/hide hyperthreaded
cores
#
Get CPU
cores
case
"
$cpu_cores
"
in
case
"
$cpu_cores
"
in
"logical"
|
"on"
) cores=
"
$(
kstat
-m
cpu_info |
grep
-c
-F
"chip_id"
)
"
;;
"logical"
|
"on"
) cores=
"
$(
kstat
-m
cpu_info |
grep
-c
-F
"chip_id"
)
"
;;
"physical"
) cores=
"
$(
psrinfo
-p
)
"
;;
"physical"
) cores=
"
$(
psrinfo
-p
)
"
;;
...
@@ -857,35 +848,33 @@ get_cpu() {
...
@@ -857,35 +848,33 @@ get_cpu() {
;;
;;
"Haiku"
)
"Haiku"
)
# Get CPU name
cpu=
"
$(
sysinfo
-cpu
|
awk
-F
'\\"'
'/CPU #0/ {print $2}'
)
"
cpu=
"
$(
sysinfo
-cpu
|
awk
-F
'\\"'
'/CPU #0/ {print $2}'
)
"
cpu=
"
${
cpu
/@*
}
"
cpu=
"
${
cpu
/@*
}
"
# Get CPU speed
speed=
"
$(
sysinfo
-cpu
|
awk
'/running at/ {print $NF; exit}'
)
"
speed=
"
$(
sysinfo
-cpu
|
awk
'/running at/ {print $NF; exit}'
)
"
speed=
"
${
speed
/MHz
}
"
speed=
"
${
speed
/MHz
}
"
speed=
"
$((
speed
/
100
))
"
speed=
"
$((
speed
/
100
))
"
# Get CPU cores
cores=
"
$(
sysinfo
-cpu
|
grep
-c
-F
'CPU #'
)
"
cores=
"
$(
sysinfo
-cpu
|
grep
-c
-F
'CPU #'
)
"
;;
;;
esac
esac
# Format the output
# Fix for speeds under 1ghz
case
"
$os
"
in
if [[
"
$speed
"
]]; then
"Mac OS X"
|
"iPhone OS"
) ;;
if [[ -z
"
${
speed
:1
}
"
]]; then
*)
speed=
"0.
${
speed
}
"
# Fix for speeds under 1ghz
else
if [[ -z
"
${
speed
:1
}
"
]]; then
speed=
"
${
speed
:0:1
}
.
${
speed
:1
}
"
speed=
"0.
${
speed
}
"
fi
else
speed=
"
${
speed
:0:1
}
.
${
speed
:1
}
"
fi
cpu=
"
$cpu
@
${
speed
}
GHz
$temp
"
cpu=
"
$cpu
@
${
speed
}
GHz
$temp
"
;;
fi
esac
# Remove uneeded patterns from cpu output
# Remove uneeded patterns from cpu output
# This is faster than sed/gsub
cpu=
"
${
cpu
//(tm)
}
"
cpu=
"
${
cpu
//(TM)
}
"
cpu=
"
${
cpu
//(TM)
}
"
cpu=
"
${
cpu
//(r)
}
"
cpu=
"
${
cpu
//(R)
}
"
cpu=
"
${
cpu
//(R)
}
"
cpu=
"
${
cpu
//CPU
}
"
cpu=
"
${
cpu
//CPU
}
"
cpu=
"
${
cpu
//Processor
}
"
cpu=
"
${
cpu
//Processor
}
"
...
@@ -910,14 +899,11 @@ get_cpu() {
...
@@ -910,14 +899,11 @@ get_cpu() {
"speed"
) cpu=
"
${
cpu
#*@
}
"
;;
"speed"
) cpu=
"
${
cpu
#*@
}
"
;;
"on"
|
"tiny"
)
"on"
|
"tiny"
)
cpu=
"
${
cpu
/AMD
}
"
cpu=
"
${
cpu
/Intel
}
"
cpu=
"
${
cpu
/Intel
}
"
cpu=
"
${
cpu
/Core
}
"
cpu=
"
${
cpu
/Core? Duo
}
"
cpu=
"
${
cpu
/Core? Duo
}
"
cpu=
"
${
cpu
/AMD
}
"
case
"
$cpu_shorthand
"
in
[[
"
$cpu_shorthand
"
==
"tiny"
]] && cpu=
"
${
cpu
/@*
}
"
"tiny"
) cpu=
"
${
cpu
/@*
}
"
;;
esac
;;
;;
esac
esac
}
}
...
@@ -2996,18 +2982,25 @@ old_functions() {
...
@@ -2996,18 +2982,25 @@ old_functions() {
fi
fi
}
}
old_
flag
s
()
{
old_
option
s
()
{
[[
-n
"
$osx_buildversion
"
]]
&&
err
"Config:
\$
osx_buildversion is deprecated, use
\$
distro_shorthand instead."
[[
-n
"
$osx_buildversion
"
]]
&&
err
"Config:
\$
osx_buildversion is deprecated, use
\$
distro_shorthand instead."
[[
-n
"
$osx_codename
"
]]
&&
err
"Config:
\$
osx_codename is deprecated, use
\$
distro_shorthand instead."
[[
-n
"
$osx_codename
"
]]
&&
err
"Config:
\$
osx_codename is deprecated, use
\$
distro_shorthand instead."
[[
"
$cpu_cores
"
==
"on"
]]
&&
err
"Config:
\$
cpu_cores='on' is deprecated, use
\$
cpu_cores='logical|physical|off' instead."
[[
"
$cpu_cores
"
==
"on"
]]
&&
err
"Config: cpu_cores='on' is deprecated, use
cpu_cores='logical|physical|off' instead."
[[
-n
"
$image
"
]]
&&
{
err
"Config:
\$
image is deprecated, use
\$
image_source instead."
;
image_source
=
"
$image
"
;
}
[[
-n
"
$image
"
]]
&&
{
err
"Config:
\$
image is deprecated, use
\$
image_source instead."
;
image_source
=
"
$image
"
;
}
# All progress_ variables were changed to bar_
# All progress_ variables were changed to bar_
[[
-n
"
$progress_char
"
]]
&&
err
"Config:
\$
progress_char is deprecated, use
\$
bar_char_elapsed and
\$
bar_char_total instead."
[[
-n
"
$progress_char
"
]]
&&
err
"Config:
\$
progress_char is deprecated, use
\$
bar_char_elapsed and
\$
bar_char_total instead."
[[
-n
"
$progress_border
"
]]
&&
err
"Config:
\$
progress_border is deprecated, use
\$
bar_border instead."
[[
-n
"
$progress_border
"
]]
&&
err
"Config:
\$
progress_border is deprecated, use
\$
bar_border instead."
[[
-n
"
$progress_length
"
]]
&&
err
"Config:
\$
progress_length is deprecated, use
\$
bar_length instead."
[[
-n
"
$progress_length
"
]]
&&
err
"Config:
\$
progress_length is deprecated, use
\$
bar_length instead."
[[
-n
"
$progress_color_elapsed
"
]]
&&
err
"Config:
\$
progress_color_elapsed is deprecated, use
\$
bar_color_elapsed instead."
[[
-n
"
$progress_color_elapsed
"
]]
&&
err
"Config:
\$
progress_color_elapsed is deprecated, use
\$
bar_color_elapsed instead."
[[
-n
"
$progress_color_total
"
]]
&&
err
"Config:
\$
progress_color_total is deprecated, use
\$
bar_color_total instead."
[[
-n
"
$progress_color_total
"
]]
&&
err
"Config:
\$
progress_color_total is deprecated, use
\$
bar_color_total instead."
# All cpufreq values were changed in 2.1.0.
# 'current', 'min', 'max', 'bios'
[[
"
$speed_type
"
==
"current"
]]
&&
err
"Config: speed_type='current' is deprecated, use speed_type='scaling_cur_freq' instead."
[[
"
$speed_type
"
==
"min"
]]
&&
err
"Config: speed_type='min' is deprecated, use speed_type='scaling_min_freq' instead."
[[
"
$speed_type
"
==
"max"
]]
&&
err
"Config: speed_type='max' is deprecated, use speed_type='scaling_max_freq' instead."
[[
"
$speed_type
"
==
"bios"
]]
&&
err
"Config: speed_type='bios' is deprecated, use speed_type='bios_limit' instead."
}
}
cache_uname
()
{
cache_uname
()
{
...
@@ -3332,7 +3325,7 @@ main() {
...
@@ -3332,7 +3325,7 @@ main() {
get_os
get_os
get_default_config 2>/dev/null
get_default_config 2>/dev/null
get_args
"
$@
"
get_args
"
$@
"
old_
flag
s
old_
option
s
get_distro
get_distro
get_bold
get_bold
get_distro_colors
get_distro_colors
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment