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
c69a8f24
Commit
c69a8f24
authored
Jun 13, 2016
by
Dylan Araps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move CPU Usage to its own function
parent
d65aa4bc
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
29 deletions
+60
-29
README.md
README.md
+2
-5
config
config/config
+8
-3
neofetch
neofetch
+50
-21
No files found.
README.md
View file @
c69a8f24
...
...
@@ -389,8 +389,6 @@ alias fetch2="fetch \
--underline_char char Character to use when underlining title
--line_wrap on/off Enable/Disable line wrapping
--bold on/off Enable/Disable bold text
--prompt_height num Set this to your prompt height to fix issues with
the text going off screen at the top
Color Blocks:
...
...
@@ -407,9 +405,8 @@ alias fetch2="fetch \
--progress_length num Length in spaces to make the progress bars.
--progress_colors num num Colors to make the progress bar.
Set in this order: elapsed, total
--cpu_display mode1 mode2 Which shorthand to use and how CPU usage should be printed
mode1 takes: name, speed, tiny, on, off
mode2 takes: info, bar, infobar, barinfo
--cpu_display mode Which way should the cpu progress bar be added
Takes bar, infobar, barinfo
--memory_display mode Which way should the memory progress bar be added
Takes bar, infobar, barinfo
--battery_display mode Which way should the battery progress bar be added
...
...
config/config
View file @
c69a8f24
...
...
@@ -99,10 +99,14 @@ shell_version="off"
# scaling_current, scaling_min, scaling_max
speed_type
=
"max"
# CPU
Display
# Set shorthand setting
and progress bar setting
# --cpu_
display (name, speed, tiny, on, off) (bar, infobar, barinfo, off)
# CPU
Shorthand
# Set shorthand setting
# --cpu_
shorthand name, speed, tiny, on, off
cpu_shorthand
=
"off"
# CPU Usage display
# Set CPU usage display setting
# --cpu_display bar, infobar, barinfo, off
cpu_display
=
"off"
# CPU Cores
...
...
@@ -111,6 +115,7 @@ cpu_display="off"
cpu_cores
=
"on"
# GPU
# Shorten output of the getgpu funcion
...
...
neofetch
View file @
c69a8f24
...
...
@@ -47,6 +47,7 @@ printinfo () {
info
"GPU"
gpu
info
"Memory"
memory
info
"CPU Usage"
cpu_usage
# info "Disk" disk
# info "Battery" battery
# info "Font" font
...
...
@@ -111,10 +112,14 @@ shell_version="off"
# scaling_current, scaling_min, scaling_max
speed_type
=
"max"
# CPU
Display
# Set shorthand setting
and progress bar setting
# --cpu_
display (name, speed, tiny, on, off) (bar, infobar, barinfo, off)
# CPU
Shorthand
# Set shorthand setting
# --cpu_
shorthand name, speed, tiny, on, off
cpu_shorthand
=
"off"
# CPU Usage display
# Set CPU usage display setting
# --cpu_display bar, infobar, barinfo, off
cpu_display
=
"off"
# CPU Cores
...
...
@@ -1147,22 +1152,50 @@ getcpu () {
[ "$cpu" ] && prin "$subtitle" "$cpu"
if [ "$cpu_display" != "off" ]; then
cpu_usage="$(ps aux | awk '
BEGIN
{
sum
=
0
}
{
sum
+=
$3
}
;
END
{
print
sum
}
')"
cpu_usage=$((${cpu_usage/\.*} / cores))
case "$cpu_display" in
"info") prin "$subtitle Usage" "${cpu_usage}%" ;;
"bar") prin "$subtitle Usage" "$(bar "$cpu_usage" 100)" ;;
"infobar") prin "$subtitle Usage" "${cpu_usage}% $(bar $cpu_usage 100)" ;;
"barinfo") prin "$subtitle Usage" "$(bar $cpu_usage 100) ${cpu_usage}%" ;;
esac
fi
[ "$stdout_mode" != "on" ] && unset cpu
}
# }}}
# CPU Usage {{{
getcpu_usage () {
case "$os" in
"Linux" | "Mac OS X" | "iPhone OS")
# Get cores if unset
if [ -z "$cores" ]; then
case "$os" in
"Linux") cores="$(awk -F '
:
' '
/
siblings/
{
printf
$2
;
exit
}
' /proc/cpuinfo)" ;;
"Mac OS X") cores="$(sysctl -n hw.ncpu)" ;;
esac
fi
cpu_usage="$(ps aux | awk '
BEGIN
{
sum
=
0
}
{
sum
+=
$3
}
;
END
{
print
sum
}
')"
cpu_usage="$((${cpu_usage/\.*} / ${cores:-1}))"
;;
"Windows")
cpu_usage="$(wmic cpu get loadpercentage /value)"
cpu_usage="${cpu_usage/LoadPercentage'
=
'}"
;;
"BSD")
# BSD support coming soon.
return
;;
esac
# Print the bar
case "$cpu_display" in
"info") cpu_usage="${cpu_usage}%" ;;
"bar") cpu_usage="$(bar $cpu_usage 100)" ;;
"infobar") cpu_usage="${cpu_usage}% $(bar $cpu_usage 100)" ;;
"barinfo") cpu_usage="$(bar $cpu_usage 100) ${cpu_usage}%" ;;
esac
}
# }}}
# GPU {{{
getgpu () {
...
...
@@ -2972,9 +3005,8 @@ usage () { cat << EOF
--progress_length num Length in spaces to make the progress bars.
--progress_colors num num Colors to make the progress bar.
Set in this order: elapsed, total
--cpu_display mode1 mode2 Which shorthand to use and how CPU usage should be printed
mode1 takes: name, speed, tiny, on, off
mode2 takes: info, bar, infobar, barinfo
--cpu_display mode Which way should the cpu progress bar be added
Takes bar, infobar, barinfo
--memory_display mode Which way should the memory progress bar be added
Takes bar, infobar, barinfo
--battery_display mode Which way should the battery progress bar be added
...
...
@@ -3119,10 +3151,7 @@ while [ "$1" ]; do
progress_color_elapsed
=
"
$2
"
progress_color_total
=
"
$3
"
;;
--cpu_display
)
cpu_shorthand
=
"
$2
"
cpu_display
=
"
$3
"
;;
--cpu_display
)
cpu_display
=
"
$2
"
;;
--memory_display
)
memory_display
=
"
$2
"
;;
--battery_display
)
battery_display
=
"
$2
"
;;
--disk_display
)
disk_display
=
"
$2
"
;;
...
...
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