Skip to content

Commit ab612fd

Browse files
authored
Fixed CPU idle percentage
1 parent c10d048 commit ab612fd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lfetch

+4-2
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,16 @@ get_uptime()
7070

7171
get_cpu_idle()
7272
{
73+
local stats e idle
74+
7375
read -r stats < /proc/stat
7476

7577
e=$(echo $stats | cut -d " " -f2)
7678
for i in {3..8}; do
7779
e="$e + $(echo $stats | cut -d " " -f$i)"
7880
done
7981

80-
echo "$(((idle * 100) / ($e))) percent"
82+
echo "$((($(echo $stats | cut -d " " -f5) * 100) / ($e))) percent"
8183
}
8284

8385
get_interrupts()
@@ -111,7 +113,7 @@ get_bootloader()
111113

112114
info()
113115
{
114-
printf "\e[1;%dm${1}\e[0;0m$("get_${2:-$1}")\n" $colour
116+
printf "\e[1;%dm%s\e[0;0m%s\n" "$colour" "${1}" "$("get_${2:-$1}")"
115117
}
116118

117119
loadcfg "/etc/lfetch.conf"

0 commit comments

Comments
 (0)