Merge pull request #594 from dylanaraps/fixes

General: Fixes
This commit is contained in:
Dylan Araps 2017-01-05 02:09:46 +11:00 committed by GitHub
commit eda20680b0

View file

@ -456,7 +456,7 @@ get_packages() {
"FreeBSD") packages="$((packages+=$(pkg info | wc -l)))" ;; "FreeBSD") packages="$((packages+=$(pkg info | wc -l)))" ;;
*) *)
packages="$((packages+=$(ls -1 /var/db/pkg | wc -l)))" packages="$((packages+=$(ls -1 /var/db/pkg | wc -l)))"
(("$packages" == "0")) && packages="$((packages+=$(pkg list | wc -l)))" ((packages == 0)) && packages="$((packages+=$(pkg list | wc -l)))"
esac esac
fi fi
;; ;;
@ -488,7 +488,7 @@ get_packages() {
;; ;;
esac esac
(("$packages" == "0")) && unset packages ((packages == 0)) && unset packages
} }
get_shell() { get_shell() {
@ -999,7 +999,7 @@ get_gpu() {
IFS="$old_ifs" IFS="$old_ifs"
# Number the GPUs if more than one exists. # Number the GPUs if more than one exists.
(( "${#gpus[@]}" > 1 )) && gpu_num=1 ((${#gpus[@]} > 1)) && gpu_num=1
for gpu in "${gpus[@]}"; do for gpu in "${gpus[@]}"; do
# GPU shorthand tests. # GPU shorthand tests.
@ -1311,7 +1311,7 @@ get_resolution() {
[[ "$resolution" == *"@ Hz"* ]] && \ [[ "$resolution" == *"@ Hz"* ]] && \
resolution="${resolution//@ Hz}" resolution="${resolution//@ Hz}"
(("${scale_factor%.*}" == 2)) && \ ((${scale_factor%.*} == 2)) && \
resolution="${resolution// @/@2x @}" resolution="${resolution// @/@2x @}"
if [[ "$refresh_rate" == "off" ]]; then if [[ "$refresh_rate" == "off" ]]; then
@ -1942,7 +1942,7 @@ get_ascii() {
# Calculate size of ascii file in line length / line count. # Calculate size of ascii file in line length / line count.
line="${line//\$\{??\}}" line="${line//\$\{??\}}"
line="${line//\\\\/\\}" line="${line//\\\\/\\}"
(("${#line}" > "${ascii_length:-0}")) && ascii_length="${#line}" ((${#line} > ascii_length)) && ascii_length="${#line}"
lines="$((lines+=1))" lines="$((lines+=1))"
done < "$ascii" done < "$ascii"
@ -2020,7 +2020,7 @@ get_wallpaper() {
image="$(awk -F'=' '/file/ {printf $2;exit;}' "${XDG_CONFIG_HOME}/nitrogen/bg-saved.cfg")" image="$(awk -F'=' '/file/ {printf $2;exit;}' "${XDG_CONFIG_HOME}/nitrogen/bg-saved.cfg")"
else else
image="$(gsettings get org.gnome.dimage=esktop.background picture-uri)" image="$(gsettings get org.gnome.desktop.background picture-uri)"
image="$(decode_url "$image")" image="$(decode_url "$image")"
fi fi
;; ;;
@ -2149,7 +2149,7 @@ get_image_size() {
image_size="$((columns * font_width / 2))" image_size="$((columns * font_width / 2))"
term_height="$((term_height - term_height / 4))" term_height="$((term_height - term_height / 4))"
(("$term_height" < "$image_size")) && \ ((term_height < image_size)) && \
image_size="$term_height" image_size="$term_height"
;; ;;
@ -2157,7 +2157,7 @@ get_image_size() {
percent="${image_size/\%}" percent="${image_size/\%}"
image_size="$((percent * term_width / 100))" image_size="$((percent * term_width / 100))"
(("$((percent * term_height / 50))" < "$image_size")) && \ (((percent * term_height / 50) < image_size)) && \
image_size="$((percent * term_height / 100))" image_size="$((percent * term_height / 100))"
;; ;;
@ -2204,7 +2204,7 @@ make_thumbnail() {
# This checks to see if height is greater than width # This checks to see if height is greater than width
# so we can do a better crop of portrait images. # so we can do a better crop of portrait images.
size="$og_height" size="$og_height"
(("$og_height" > "$og_width")) && size="$og_width" ((og_height > og_width)) && size="$og_width"
fi fi
case "$crop_mode" in case "$crop_mode" in
@ -2486,7 +2486,7 @@ trim_quotes() {
} }
uppercase() { uppercase() {
(("$bash_version" >= 4)) && printf "%s" "${1^}" ((bash_version >= 4)) && printf "%s" "${1^}"
} }
# COLORS # COLORS
@ -3067,12 +3067,12 @@ set_text_colors() {
info_color="$reset" info_color="$reset"
# If the ascii art uses 8 as a color, make the text the fg. # If the ascii art uses 8 as a color, make the text the fg.
(("$1" == 8)) && title_color="$reset" ((${1:-1} == 8)) && title_color="$reset"
(("$2" == 8)) && subtitle_color="$reset" ((${2:-7} == 8)) && subtitle_color="$reset"
# If the second color is white use the first for the subtitle. # If the second color is white use the first for the subtitle.
(("$2" == 7)) && subtitle_color="$(color "$1")" ((${2:-7} == 7)) && subtitle_color="$(color "$1")"
(("$1" == 7)) && title_color="$reset" ((${1:-1} == 7)) && title_color="$reset"
else else
title_color="$(color "${colors[0]}")" title_color="$(color "${colors[0]}")"
at_color="$(color "${colors[1]}")" at_color="$(color "${colors[1]}")"
@ -3283,7 +3283,7 @@ dynamic_prompt() {
# If the info is higher than the ascii/image place the prompt # If the info is higher than the ascii/image place the prompt
# based on the info height instead of the ascii/image height. # based on the info height instead of the ascii/image height.
if (("${lines:-0}" < "${info_height:-0}")); then if ((lines < info_height)); then
printf "\n" printf "\n"
return return
else else
@ -3291,7 +3291,7 @@ dynamic_prompt() {
fi fi
# Set the prompt location. # Set the prompt location.
if (("$lines" < 0)); then if ((lines < 0)); then
printf "%b" "\033[${lines/-}A" printf "%b" "\033[${lines/-}A"
else else
printf "%b" "\033[${lines}B" printf "%b" "\033[${lines}B"
@ -3700,7 +3700,7 @@ get_args() {
"--disable") continue ;; "--disable") continue ;;
"-"*) break ;; "-"*) break ;;
*) *)
(("$bash_version" >= 4)) && func="${func,,}" ((bash_version >= 4)) && func="${func,,}"
unset -f "get_$func" unset -f "get_$func"
;; ;;
esac esac