Fix conflicts

This commit is contained in:
Dylan Araps 2016-12-09 16:20:10 +11:00
commit 42cae93481
3 changed files with 49 additions and 21 deletions

View File

@ -1,13 +1,23 @@
language: bash language: bash
sudo: required sudo: required
addons:
apt:
sources:
- debian-sid
packages:
- shellcheck
os: os:
- linux - linux
- osx - osx
before_install: before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install screenresolution; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install screenresolution; fi
script: script:
- time ./neofetch --ascii --config travis -v - time ./neofetch --ascii --config travis -v
# See this wiki page for why we're disabling these errors.
# https://github.com/dylanaraps/neofetch/wiki/Shellcheck-Exclusions
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then shellcheck neofetch -e SC1090,SC2009,SC2012,SC2016,SC2034,SC2128,SC2153,SC2154,SC2178,SC2010; fi

View File

@ -1,6 +1,14 @@
## Contributors ## Contributors
## General
- Travis now runs [shellcheck](https://github.com/koalaman/shellcheck) on every commit and pull request.
- We've had to exclude around 10 lint errors, see this wiki page for why we did this:
- https://github.com/dylanaraps/neofetch/wiki/Shellcheck-Exclusions
- Optimize usage of get_de(), get_wm() and get_term().
- We were calling these multiple times, we now check to see if they were run previously.
## Images ## Images
- [iTerm2] Fixed blank images. - [iTerm2] Fixed blank images.

View File

@ -44,7 +44,7 @@ get_distro() {
case "$os" in case "$os" in
"Linux" | "GNU") "Linux" | "GNU")
if [[ "$(< /proc/version)" =~ "Microsoft" || "$(< /proc/sys/kernel/osrelease)" =~ "Microsoft" ]]; then if [[ "$(< /proc/version)" == *"Microsoft"* || "$(< /proc/sys/kernel/osrelease)" == *"Microsoft"* ]]; then
case "$distro_shorthand" in case "$distro_shorthand" in
"on") distro="$(lsb_release -sir) [Windows 10]" ;; "on") distro="$(lsb_release -sir) [Windows 10]" ;;
"tiny") distro="Windows 10" ;; "tiny") distro="Windows 10" ;;
@ -283,7 +283,7 @@ get_kernel() {
esac esac
# Hardcode kernel settings in BSDs # Hardcode kernel settings in BSDs
if [[ "$os" == "BSD" && "$distro" =~ "$kernel_name" ]]; then if [[ "$os" == "BSD" && "$distro" == *"$kernel_name"* ]]; then
case "$distro_shorthand" in case "$distro_shorthand" in
"on" | "tiny") kernel="$kernel_version" ;; "on" | "tiny") kernel="$kernel_version" ;;
*) unset kernel ;; *) unset kernel ;;
@ -555,6 +555,9 @@ get_de() {
*"xfce4"*) de="XFCE4" ;; *"xfce4"*) de="XFCE4" ;;
*"xfce5"*) de="XFCE5" ;; *"xfce5"*) de="XFCE5" ;;
esac esac
# Log that the function was run.
de_run=1
} }
get_wm() { get_wm() {
@ -579,11 +582,14 @@ get_wm() {
;; ;;
esac esac
fi fi
# Log that the function was run.
wm_run=1
} }
get_wm_theme() { get_wm_theme() {
[[ -z "$wm" ]] && get_wm (( "$wm_run" != 1 )) && get_wm
[[ -z "$de" ]] && get_de (( "$de_run" != 1 )) && get_de
case "$wm" in case "$wm" in
"E16") wm_theme="$(awk -F "= " '/theme.name/ {print $2}' "$HOME/.e16/e_config--0.0.cfg")";; "E16") wm_theme="$(awk -F "= " '/theme.name/ {print $2}' "$HOME/.e16/e_config--0.0.cfg")";;
@ -965,7 +971,7 @@ get_gpu() {
;; ;;
esac esac
[[ "$gpu" =~ "intel" ]] && \ [[ "$gpu" == *"intel"* ]] && \
gpu="Intel Integrated Graphics" gpu="Intel Integrated Graphics"
;; ;;
@ -1294,7 +1300,7 @@ get_resolution() {
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)"
# If no refresh rate is empty. # If no refresh rate is empty.
[[ "$resolution" =~ "@ Hz" ]] && \ [[ "$resolution" == *"@ Hz"* ]] && \
resolution="${resolution//@ Hz}" resolution="${resolution//@ Hz}"
(("${scale_factor%.*}" == 2)) && \ (("${scale_factor%.*}" == 2)) && \
@ -1305,7 +1311,7 @@ get_resolution() {
resolution="${resolution// @ [0-9][0-9][0-9]Hz}" resolution="${resolution// @ [0-9][0-9][0-9]Hz}"
fi fi
[[ "$resolution" =~ "0Hz" ]] && \ [[ "$resolution" == *"0Hz"* ]] && \
resolution="${resolution// @ 0Hz}" resolution="${resolution// @ 0Hz}"
;; ;;
@ -1336,7 +1342,7 @@ get_style() {
if [[ -n "$DISPLAY" && "$os" != "Mac OS X" ]]; then if [[ -n "$DISPLAY" && "$os" != "Mac OS X" ]]; then
# Get DE if user has disabled the function. # Get DE if user has disabled the function.
[[ -z "$de" ]] && get_de (( "$de_run" != 1 )) && get_de
# Check for DE Theme. # Check for DE Theme.
case "$de" in case "$de" in
@ -1531,10 +1537,13 @@ get_term() {
"gnome-terminal-") term="gnome-terminal" ;; "gnome-terminal-") term="gnome-terminal" ;;
*) term="${name##*/}" ;; *) term="${name##*/}" ;;
esac esac
# Log that the function was run.
term_run=1
} }
get_term_font() { get_term_font() {
[[ -z "$term" ]] && get_term (( "$term_run" != 1 )) && get_term
case "$term" in case "$term" in
"urxvt" | "urxvtd" | "xterm") "urxvt" | "urxvtd" | "xterm")
@ -1588,11 +1597,11 @@ get_disk() {
# df flags # df flags
case "$os" in case "$os" in
"Linux" | "iPhone OS" | "Windows" | "Solaris" | "GNU") "Linux" | "iPhone OS" | "Windows" | "Solaris" | "GNU")
df_flags="-h -l --total" df_flags=(-h -l --total)
df_dir="total" df_dir="total"
case "$distro" in case "$distro" in
"OpenWRT"*) df_flags="-h"; df_dir="rootfs" ;; "OpenWRT"*) df_flags=(-h); df_dir="rootfs" ;;
"Android"*) return ;; "Android"*) return ;;
esac esac
;; ;;
@ -1600,7 +1609,7 @@ get_disk() {
"Mac OS X" | "BSD" | "Haiku") "Mac OS X" | "BSD" | "Haiku")
case "$distro" in case "$distro" in
"FreeBSD"* | *"OS X"* | "Mac"*) "FreeBSD"* | *"OS X"* | "Mac"*)
df_flags="-l -H /" df_flags=(-l -H /)
df_dir="/" df_dir="/"
;; ;;
@ -1610,7 +1619,7 @@ get_disk() {
esac esac
# Get the disk info # Get the disk info
disk="$(df $df_flags | awk -v dir="$df_dir" '$0 ~ dir {print $2 ":" $3 ":" $5}')" disk="$(df "${df_flags[@]}" | awk -v dir="$df_dir" '$0 ~ dir {print $2 ":" $3 ":" $5}')"
# Format the output # Format the output
disk_used="${disk#*:}" disk_used="${disk#*:}"
@ -2033,7 +2042,7 @@ get_wallpaper() {
case "$os" in case "$os" in
"Linux" | "BSD" | "Solaris" | "GNU") "Linux" | "BSD" | "Solaris" | "GNU")
# Get DE if user has disabled the function. # Get DE if user has disabled the function.
[[ -z "$de" ]] && get_de (( "$de_run" != 1 )) && get_de
case "$de" in case "$de" in
"Cinnamon"*) image="$(gsettings get org.cinnamon.desktop.background picture-uri)" ;; "Cinnamon"*) image="$(gsettings get org.cinnamon.desktop.background picture-uri)" ;;
@ -2096,20 +2105,20 @@ get_term_size() {
# get the terminal size. # get the terminal size.
if [[ -n "$TMUX" ]]; then if [[ -n "$TMUX" ]]; then
printf "%b" "\033Ptmux;\033\033[14t\033\033[c\033\\" printf "%b" "\033Ptmux;\033\033[14t\033\033[c\033\\"
read_flags="-d c" read_flags=(-d c)
elif [[ "$image_program" == "tycat" ]]; then elif [[ "$image_program" == "tycat" ]]; then
printf "%b" "\033}qs\000" printf "%b" "\033}qs\000"
else else
printf "%b" "\033[14t\033[c" printf "%b" "\033[14t\033[c"
read_flags="-d c" read_flags=(-d c)
fi fi
# The escape codes above print the desired output as # The escape codes above print the desired output as
# user input so we have to use read to store the out # user input so we have to use read to store the out
# -put as a variable. # -put as a variable.
builtin read -s -t 1 ${read_flags} -r term_size builtin read -s -t 1 "${read_flags[@]}" -r term_size
# Split the string into height/width. # Split the string into height/width.
if [[ "$image_program" == "tycat" ]]; then if [[ "$image_program" == "tycat" ]]; then
@ -2529,6 +2538,7 @@ trim() {
# '${1//[[:space:]]/ }' to remove newlines beofre we trim the whitespace. # '${1//[[:space:]]/ }' to remove newlines beofre we trim the whitespace.
set -f set -f
# shellcheck disable=2086
builtin echo -E ${1//[[:space:]]/ } builtin echo -E ${1//[[:space:]]/ }
set +f set +f
} }
@ -2712,7 +2722,7 @@ get_distro_colors() {
# equal 'distro'. # equal 'distro'.
if [[ "${ascii_colors[0]}" != "distro" ]]; then if [[ "${ascii_colors[0]}" != "distro" ]]; then
color_text="off" color_text="off"
set_colors ${ascii_colors[@]} set_colors "${ascii_colors[@]}"
fi fi
} }
@ -2724,7 +2734,7 @@ set_colors() {
c5="$(color "$5")${ascii_bold}" c5="$(color "$5")${ascii_bold}"
c6="$(color "$6")${ascii_bold}" c6="$(color "$6")${ascii_bold}"
[[ "$color_text" != "off" ]] && set_text_colors $@ [[ "$color_text" != "off" ]] && set_text_colors "$@"
} }
set_text_colors() { set_text_colors() {
@ -2924,7 +2934,7 @@ get_term_padding() {
# #
# Note: This issue only seems to affect # Note: This issue only seems to affect
# URxvt. # URxvt.
[[ -z "$term" ]] && get_term (( "$term_run" != 1 )) && get_term
case "$term" in case "$term" in
"URxvt"*) "URxvt"*)