General: Function cleanup

This commit is contained in:
Dylan Araps 2016-11-06 17:35:59 +11:00
parent 5288a609e5
commit 37dd5d5741
1 changed files with 13 additions and 18 deletions

View File

@ -1088,13 +1088,15 @@ getmemory() {
"BSD") "BSD")
case "$distro" in case "$distro" in
"NetBSD"*) memfree="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))" ;; "NetBSD"*)
*) memfree="$(($(vmstat | awk 'END{printf $5}') / 1024))" ;; memfree="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))"
esac memtotal="$(($(sysctl -n hw.physmem64) / 1024 / 1024))"
;;
case "$distro" in *)
"NetBSD"*) memtotal="$(($(sysctl -n hw.physmem64) / 1024 / 1024))" ;; memfree="$(($(vmstat | awk 'END{printf $5}') / 1024))"
*) memtotal="$(($(sysctl -n hw.physmem) / 1024 / 1024))" ;; memtotal="$(($(sysctl -n hw.physmem) / 1024 / 1024))"
;;
esac esac
case "$distro" in case "$distro" in
@ -1269,8 +1271,7 @@ getresolution() {
resolution="${resolution//x??@/ @ }" resolution="${resolution//x??@/ @ }"
else else
resolution="$(system_profiler SPDisplaysDataType |\ resolution="$(system_profiler SPDisplaysDataType | awk '/Resolution:/ {printf $2"x"$4" @ "$6"Hz, "}')"
awk '/Resolution:/ {printf $2"x"$4" @ "$6"Hz, "}')"
fi fi
scale_factor="$(/usr/libexec/PlistBuddy -c "Print DisplayAnyUserSets:0:0:Resolution" /Library/Preferences/com.apple.windowserver.plist)" scale_factor="$(/usr/libexec/PlistBuddy -c "Print DisplayAnyUserSets:0:0:Resolution" /Library/Preferences/com.apple.windowserver.plist)"
@ -1294,16 +1295,13 @@ getresolution() {
height="$(wmic path Win32_VideoController get CurrentVerticalResolution /value)" height="$(wmic path Win32_VideoController get CurrentVerticalResolution /value)"
height="${height/CurrentVerticalResolution'='/}" height="${height/CurrentVerticalResolution'='/}"
[ "$width" ] && \ [ "$width" ] && resolution="${width}x${height}"
resolution="${width}x${height}"
;; ;;
"Haiku") "Haiku")
resolution="$(screenmode | awk -F ' |, ' '{printf $2 "x" $3 " @ " $6 $7}')" resolution="$(screenmode | awk -F ' |, ' '{printf $2 "x" $3 " @ " $6 $7}')"
case "$refresh_rate" in [ "$refresh_rate" == "off" ] && resolution="${resolution/ @*}"
"off") resolution="${resolution/ @*}" ;;
esac
;; ;;
esac esac
@ -1719,8 +1717,7 @@ getbattery() {
"Windows") "Windows")
battery="$(wmic Path Win32_Battery get EstimatedChargeRemaining /value)" battery="$(wmic Path Win32_Battery get EstimatedChargeRemaining /value)"
battery="${battery/EstimatedChargeRemaining'='}" battery="${battery/EstimatedChargeRemaining'='}"
[ "$battery" ] && \ [ "$battery" ] && battery+="%"
battery+="%"
;; ;;
"Haiku") "Haiku")
@ -1730,9 +1727,7 @@ getbattery() {
;; ;;
esac esac
case "$battery_state" in [ "$battery_state" ] && battery+=" Charging"
"charging"*) battery+=" Charging" ;;
esac
case "$battery_display" in case "$battery_display" in
"bar") battery="$(bar "${battery/'%'*}" 100)" ;; "bar") battery="$(bar "${battery/'%'*}" 100)" ;;