General: Cleanup / Fixes

This commit is contained in:
Dylan Araps 2016-11-15 22:27:36 +11:00
parent e06c6d4ac7
commit 85c4e8ce4a

156
neofetch
View file

@ -410,16 +410,16 @@ get_packages() {
"Mac OS X")
[[ -d "/usr/local/bin" ]] && \
packages="$(($(ls -l /usr/local/bin/ | grep -cv "\(../Cellar/\|brew\)") - 1))"
packages="$(("$(ls -l /usr/local/bin/ | grep -cv "\(../Cellar/\|brew\)")" - 1))"
type -p port >/dev/null && \
packages="$((packages + $(port installed | wc -l) - 1))"
packages="$((packages + "$(port installed | wc -l)" - 1))"
type -p brew >/dev/null && \
packages="$((packages + $(find /usr/local/Cellar -maxdepth 1 | wc -l) - 1))"
packages="$((packages + "$(find /usr/local/Cellar -maxdepth 1 | wc -l)" - 1))"
type -p pkgin >/dev/null && \
packages="$((packages + $(pkgin list | wc -l)))"
packages="$((packages + "$(pkgin list | wc -l)"))"
;;
"BSD")
@ -1026,7 +1026,7 @@ get_memory() {
;;
"Mac OS X" | "iPhone OS")
memtotal="$(($(sysctl -n hw.memsize) / 1024^2))"
memtotal="$(("$(sysctl -n hw.memsize)" / 1024^2))"
memwired="$(vm_stat | awk '/wired/ { print $4 }')"
memactive="$(vm_stat | awk '/active / { printf $3 }')"
memcompressed="$(vm_stat | awk '/occupied/ { printf $5 }')"
@ -1036,18 +1036,18 @@ get_memory() {
"BSD")
case "$distro" in
"NetBSD"*)
memfree="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))"
memtotal="$(($(sysctl -n hw.physmem64) / 1024^2))"
memfree="$(("$(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo)" / 1024))"
memtotal="$(("$(sysctl -n hw.physmem64)" / 1024^2))"
;;
*)
memfree="$(($(vmstat | awk 'END{printf $5}') / 1024))"
memtotal="$(($(sysctl -n hw.physmem) / 1024^2))"
memfree="$(("$(vmstat | awk 'END{printf $5}')" / 1024))"
memtotal="$(("$(sysctl -n hw.physmem)" / 1024^2))"
;;
esac
case "$distro" in
"OpenBSD"*) memused="$(($(vmstat | awk 'END {printf $4}') / 1024))" ;;
"OpenBSD"*) memused="$(("$(vmstat | awk 'END {printf $4}')" / 1024))" ;;
*) memused="$((memtotal - memfree))" ;;
esac
;;
@ -1253,7 +1253,7 @@ get_style() {
unset gtk2theme gtk3theme theme path
case "$1" in
theme)
"theme")
name="gtk-theme-name"
gsettings="gtk-theme"
gconf="gtk_theme"
@ -1261,7 +1261,7 @@ get_style() {
kde="widgetStyle"
;;
icons)
"icons")
name="gtk-icon-theme-name"
gsettings="icon-theme"
gconf="icon_theme"
@ -1269,7 +1269,7 @@ get_style() {
kde="Theme"
;;
font)
"font")
name="gtk-font-name"
gsettings="font-name"
gconf="font_theme"
@ -2977,39 +2977,39 @@ get_args() {
while [[ "$1" ]]; do
case "$1" in
# Info
--os_arch) os_arch="$2" ;;
--cpu_cores) cpu_cores="$2" ;;
--cpu_speed) cpu_speed="$2" ;;
--cpu_temp) cpu_temp="$2" ;;
--speed_type) speed_type="$2" ;;
--distro_shorthand) distro_shorthand="$2" ;;
--kernel_shorthand) kernel_shorthand="$2" ;;
--uptime_shorthand) uptime_shorthand="$2" ;;
--cpu_shorthand) cpu_shorthand="$2" ;;
--gpu_brand) gpu_brand="$2" ;;
--refresh_rate) refresh_rate="$2" ;;
--gtk_shorthand) gtk_shorthand="$2" ;;
--gtk2) gtk2="$2" ;;
--gtk3) gtk3="$2" ;;
--shell_path) shell_path="$2" ;;
--shell_version) shell_version="$2" ;;
--ip_host) public_ip_host="$2" ;;
--song_shorthand) song_shorthand="$2" ;;
--birthday_shorthand) birthday_shorthand="$2" ;;
--birthday_time) birthday_time="$2" ;;
--birthday_format) birthday_format="$2" ;;
--disable)
"--os_arch") os_arch="$2" ;;
"--cpu_cores") cpu_cores="$2" ;;
"--cpu_speed") cpu_speed="$2" ;;
"--cpu_temp") cpu_temp="$2" ;;
"--speed_type") speed_type="$2" ;;
"--distro_shorthand") distro_shorthand="$2" ;;
"--kernel_shorthand") kernel_shorthand="$2" ;;
"--uptime_shorthand") uptime_shorthand="$2" ;;
"--cpu_shorthand") cpu_shorthand="$2" ;;
"--gpu_brand") gpu_brand="$2" ;;
"--refresh_rate") refresh_rate="$2" ;;
"--gtk_shorthand") gtk_shorthand="$2" ;;
"--gtk2") gtk2="$2" ;;
"--gtk3") gtk3="$2" ;;
"--shell_path") shell_path="$2" ;;
"--shell_version") shell_version="$2" ;;
"--ip_host") public_ip_host="$2" ;;
"--song_shorthand") song_shorthand="$2" ;;
"--birthday_shorthand") birthday_shorthand="$2" ;;
"--birthday_time") birthday_time="$2" ;;
"--birthday_format") birthday_format="$2" ;;
"--disable")
for func in "$@"; do
case "$func" in
"--disable") continue ;;
"-"*) return ;;
"-"*) break ;;
*) unset -f "get_$func" ;;
esac
done
;;
# Text Colors
--colors)
"--colors")
unset colors
for arg in "$2" "$3" "$4" "$5" "$6" "$7"; do
case "$arg" in
@ -3021,60 +3021,62 @@ get_args() {
;;
# Text Formatting
--underline) underline_enabled="$2" ;;
--underline_char) underline_char="$2" ;;
--bold) bold="$2" ;;
"--underline") underline_enabled="$2" ;;
"--underline_char") underline_char="$2" ;;
"--bold") bold="$2" ;;
# Color Blocks
--color_blocks) color_blocks="$2" ;;
--block_range) start="$2"; end="$3" ;;
--block_width) block_width="$2" ;;
--block_height) block_height="$2" ;;
"--color_blocks") color_blocks="$2" ;;
"--block_range") start="$2"; end="$3" ;;
"--block_width") block_width="$2" ;;
"--block_height") block_height="$2" ;;
# Bars
--bar_char)
"--bar_char")
bar_char_elapsed="$2"
bar_char_total="$3"
;;
--bar_border) bar_border="$2" ;;
--bar_length) bar_length="$2" ;;
--bar_colors)
"--bar_border") bar_border="$2" ;;
"--bar_length") bar_length="$2" ;;
"--bar_colors")
bar_color_elapsed="$2"
bar_color_total="$3"
;;
--cpu_display) cpu_display="$2" ;;
--memory_display) memory_display="$2" ;;
--battery_display) battery_display="$2" ;;
--disk_display) disk_display="$2" ;;
"--cpu_display") cpu_display="$2" ;;
"--memory_display") memory_display="$2" ;;
"--battery_display") battery_display="$2" ;;
"--disk_display") disk_display="$2" ;;
# Image
--image)
"--image")
image_source="$2"
case "$2" in "-"* | "") image_backend="ascii" ;; esac
;;
--image_size | --size) image_size="$2" ;;
--crop_mode) crop_mode="$2" ;;
--crop_offset) crop_offset="$2" ;;
--xoffset) xoffset="$2" ;;
--yoffset) yoffset="$2" ;;
--background_color | --bg_color) background_color="$2" ;;
--gap) gap="$2" ;;
--clean)
rm -rf "$thumbnail_dir"
"--image_size" | "--size") image_size="$2" ;;
"--crop_mode") crop_mode="$2" ;;
"--crop_offset") crop_offset="$2" ;;
"--xoffset") xoffset="$2" ;;
"--yoffset") yoffset="$2" ;;
"--background_color" | "--bg_color") background_color="$2" ;;
"--gap") gap="$2" ;;
"--clean")
rm -rf "${thumbnail_dir:="$HOME/.cache/thumbnails/neofetch"}"
rm -rf "/Library/Caches/neofetch/"
rm -rf "/tmp/neofetch/"
exit
;;
# Ascii
--ascii)
"--ascii")
image_backend="ascii"
ascii="$2"
case "$2" in "-"* | "") ascii="distro" ;; esac
;;
--ascii_colors)
"--ascii_colors")
unset ascii_colors
for arg in "$2" "$3" "$4" "$5" "$6" "$7"; do
case "$arg" in
@ -3085,43 +3087,43 @@ get_args() {
ascii_colors+=(7 7 7 7 7 7)
;;
--ascii_distro)
"--ascii_distro")
image_backend="ascii"
ascii_distro="$2"
case "$2" in "-"* | "") ascii_distro="$distro" ;; esac
;;
--ascii_logo_size) ascii_logo_size="$2" ;;
--ascii_bold) ascii_bold="$2" ;;
--logo | -L)
"--ascii_logo_size") ascii_logo_size="$2" ;;
"--ascii_bold") ascii_bold="$2" ;;
"--logo" | "-L")
image_backend="ascii"
print_info() { info line_break; }
;;
# Screenshot
--scrot | -s)
"--scrot" | "-s")
scrot_args "$@"
;;
--upload | -su)
"--upload" | "-su")
scrot_upload="on"
scrot_args "$@"
;;
--image_host) image_host="$2" ;;
--scrot_cmd) scrot_cmd="$2" ;;
"--image_host") image_host="$2" ;;
"--scrot_cmd") scrot_cmd="$2" ;;
# Other
--config)
"--config")
case "$2" in
"none" | "off") config="off" ;;
*) config_file="$2"; config="on"; get_user_config 2>/dev/null ;;
esac
;;
-v) verbose="on" ;;
-vv) set -x; verbose="on" ;;
--help) usage ;;
--version) printf "%s\n" "Neofetch 2.0"; exit ;;
"-v") verbose="on" ;;
"-vv") set -x; verbose="on" ;;
"--help") usage ;;
"--version") printf "%s\n" "Neofetch 2.0"; exit ;;
esac
shift