Script is now even faster.
This commit is contained in:
parent
b6dc6ed22b
commit
c3c8c23d1d
40
fetch.sh
40
fetch.sh
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
# Speed up script by not using unicode
|
# Speed up script by not using unicode
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
|
export LANG=C
|
||||||
|
|
||||||
|
|
||||||
# Config Options {{{
|
# Config Options {{{
|
||||||
|
@ -224,8 +225,8 @@ getdistro () {
|
||||||
if type -p crux >/dev/null 2>&1; then
|
if type -p crux >/dev/null 2>&1; then
|
||||||
distro="CRUX"
|
distro="CRUX"
|
||||||
else
|
else
|
||||||
distro="$(awk -F'=' '/^NAME=/ {printf $2; exit}' /etc/*ease)"
|
distro="$(grep -h '^NAME=' /etc/*ease)"
|
||||||
distro=${distro#\"*}
|
distro=${distro#NAME\=\"*}
|
||||||
distro=${distro%*\"}
|
distro=${distro%*\"}
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
@ -375,8 +376,9 @@ getwindowmanager () {
|
||||||
windowmanager="$XDG_CURRENT_DESKTOP"
|
windowmanager="$XDG_CURRENT_DESKTOP"
|
||||||
|
|
||||||
elif [ -e "$HOME/.xinitrc" ]; then
|
elif [ -e "$HOME/.xinitrc" ]; then
|
||||||
xinitrc=$(awk '/^[^#]*exec/ {print $2}' "${HOME}/.xinitrc")
|
xinitrc=$(grep "^[^#]*exec" "${HOME}/.xinitrc")
|
||||||
windowmanager="${xinitrc/-session/}"
|
windowmanager="${xinitrc/exec /}"
|
||||||
|
windowmanager="${windowmanager/-session/}"
|
||||||
|
|
||||||
else
|
else
|
||||||
case "$os" in
|
case "$os" in
|
||||||
|
@ -397,7 +399,8 @@ getcpu () {
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux")
|
"Linux")
|
||||||
# Get cpu name
|
# Get cpu name
|
||||||
cpu="$(awk -F ': ' '/model name/ {printf $2; exit}' /proc/cpuinfo)"
|
cpu="$(grep 'model name' /proc/cpuinfo)"
|
||||||
|
cpu=${cpu/model name*: /}
|
||||||
|
|
||||||
# Get cpu speed
|
# Get cpu speed
|
||||||
speed_type=${speed_type/rent/}
|
speed_type=${speed_type/rent/}
|
||||||
|
@ -437,17 +440,26 @@ getcpu () {
|
||||||
getmemory () {
|
getmemory () {
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux")
|
"Linux")
|
||||||
mem="$(awk 'NR < 4 {printf $2 " "}' /proc/meminfo)"
|
# Read first 3 lines
|
||||||
|
exec 6< /proc/meminfo
|
||||||
|
read memtotal <&6
|
||||||
|
read memfree <&6
|
||||||
|
read memavail <&6
|
||||||
|
exec 6<&-
|
||||||
|
|
||||||
# Split the string above into 3 vars
|
# Do some substitution on each line
|
||||||
# This is faster than using an array.
|
memtotal=${memtotal/MemTotal:/}
|
||||||
set $mem
|
memtotal=${memtotal/kB*/}
|
||||||
|
memtotal=${memtotal// /}
|
||||||
|
memfree=${memfree/MemFree:/}
|
||||||
|
memfree=${memfree/kB*/}
|
||||||
|
memfree=${memfree// /}
|
||||||
|
memavail=${memavail/MemAvailable:/}
|
||||||
|
memavail=${memavail/kB*/}
|
||||||
|
memavail=${memavail// /}
|
||||||
|
|
||||||
memtotal=$1
|
memused=$((memtotal - memavail))
|
||||||
memfree=$2
|
memory="$(($memused / 1024))MB / $(($memtotal / 1024))MB"
|
||||||
memavail=$3
|
|
||||||
memused="$((memtotal - memavail))"
|
|
||||||
memory="$(( ${memused%% *} / 1024))MB / $(( ${memtotal%% *} / 1024))MB"
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Mac OS X")
|
"Mac OS X")
|
||||||
|
|
Reference in New Issue