From b22f6fc44cd55d9e96e8519dbabd2c2bc130336a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 09:47:09 +1000 Subject: [PATCH 01/16] Source the default config file --- neofetch | 432 ++++--------------------------------------------------- 1 file changed, 24 insertions(+), 408 deletions(-) diff --git a/neofetch b/neofetch index 4713f66e..69d65540 100755 --- a/neofetch +++ b/neofetch @@ -16,413 +16,6 @@ XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}" export LC_ALL=C export LANG=C - -# Config Options {{{ - - -# Info Options {{{ - - -# Info -# See this wiki page for more info: -# https://github.com/dylanaraps/neofetch/wiki/Customizing-Info -printinfo () { - info title - info underline - - info "OS" distro - info "Kernel" kernel - info "Uptime" uptime - info "Packages" packages - info "Shell" shell - info "Resolution" resolution - info "DE" de - info "WM" wm - info "WM Theme" wmtheme - info "Theme" theme - info "Icons" icons - info "Terminal" term - info "Terminal Font" termfont - info "CPU" cpu - info "GPU" gpu - info "Memory" memory - - # info "CPU Usage" cpu_usage - # info "Disk" disk - # info "Battery" battery - # info "Font" font - # info "Song" song - # info "Local IP" localip - # info "Public IP" publicip - # info "Users" users - # info "Birthday" birthday - - info linebreak - info cols - info linebreak -} - - -# Kernel - -# Show more kernel info -# --kernel_shorthand on/off -kernel_shorthand="on" - - -# Distro - -# Mac OS X hide/show build version -# --osx_buildversion on/off -osx_buildversion="on" - -# Mac OS X hide/show codename -# --osx_codename on/off -osx_codename="on" - -# Show 'x86_64' and 'x86' in 'Distro:' output. -# --os_arch on/off -os_arch="on" - - -# Uptime - -# Shorten the output of the uptime function -# --uptime_shorthand tiny, on, off -uptime_shorthand="off" - - -# Shell - -# Show the path to $SHELL -# --shell_path on/off -shell_path="on" - -# Show $SHELL's version -# --shell_version on/off -shell_version="off" - - -# CPU - -# CPU speed type -# Only works on Linux with cpufreq. -# --speed_type current, min, max, bios, -# scaling_current, scaling_min, scaling_max -speed_type="max" - -# CPU Shorthand -# Set shorthand setting -# --cpu_shorthand name, speed, tiny, on, off -cpu_shorthand="off" - -# CPU Cores -# Display CPU cores in output -# --cpu_cores on/off -cpu_cores="on" - -# GPU - -# Shorten output of the getgpu funcion -# --gpu_shorthand on/off/tiny -gpu_shorthand="on" - -# Resolution - -# Display refresh rate next to each monitor -# Unsupported on Windows -# --refresh_rate on/off -refresh_rate="off" - -# Gtk Theme / Icons - -# Shorten output (Hide [GTK2] etc) -# --gtk_shorthand on/off -gtk_shorthand="off" - - -# Enable/Disable gtk2 theme/icons output -# --gtk2 on/off -gtk2="on" - -# Enable/Disable gtk3 theme/icons output -# --gtk3 on/off -gtk3="on" - - -# Battery - -# Which battery to display. -# By default we display all batteries. -# NOTE: Only works on Linux. -# --battery_num all, 0, 1, 2, etc -battery_num="all" - -# Whether or not to print each battery on the same line. -# By default each battery gets its own line and title. -# NOTE: Only works on Linux. -# --battery_shorthand on/off -battery_shorthand="off" - - -# IP Address - -# Website to ping for the public IP -# --ip_host url -public_ip_host="http://ident.me" - - -# Song - -# Print the Artist and Title on seperate lines -# --song_shorthand on/off -song_shorthand="off" - - -# Birthday - -# Whether to show a long pretty output -# or a shortened one -# NOTE: Long pretty output doesn't work on OpenBSD or NetBSD. -# --birthday_shorthand on/off -birthday_shorthand="off" - -# Whether to show the time in the output -# --birthday_time on/off -birthday_time="on" - -# Date format to use when printing birthday -# --birthday_format "format" -birthday_format="%a %d %b %Y %l:%M %p" - - -# }}} - -# Text Colors {{{ - - -# Text Colors -# Each number represents a different part of -# the text in this order: -# title, @, underline, subtitle, colon, info -# colors=(4 6 1 8 8 6) -# You can also specify: -# fg (foreground color) -colors=(distro) - - -# }}} - -# Text Options {{{ - - -# Toggle bold text -# --bold on/off -bold="on" - -# Enable/Disable Underline -# --underline on/off -underline_enabled="on" - -# Underline character -# --underline_char char -underline_char="-" - - -# }}} - -# Color Blocks {{{ - - -# Color block range -# --block_range start end -start=0 -end=7 - -# Toggle color blocks -# --color_blocks on/off -color_blocks="on" - -# Color block width in spaces -# --block_width num -block_width=2 - -# Color block height in lines -# --block_height num -block_height=1 - - -# }}} - -# Progress Bars {{{ - - -# Progress bar character -# --progress_char elapsed_char total_char -progress_char_elapsed="=" -progress_char_total="-" - -# Progress vorder -# --progress_border on/off -progress_border="on" - -# Progress bar length in spaces -# Number of chars long to make the progress bars. -# --progress_length num -progress_length="15" - -# Progress bar colors -# When set to distro, uses your distro's logo colors -# Takes: num, "distro" -# --progress_colors col col -progress_color_elapsed="distro" -progress_color_total="distro" - -# Customize how the info is displayed. -# bar: Only the progress bar is displayed. -# infobar: The bar is displayed after the info. -# barinfo: The bar is displayed before the info. -# off: Only the info is displayed. -# -# --cpu_display bar/infobar/barinfo/off -# --memory_display bar/infobar/barinfo/off -# --battery_display bar/infobar/barinfo/off -# --disk_display bar/infobar/barinfo/off -cpu_display="off" -memory_display="off" -battery_display="off" -disk_display="off" - - -# }}} - -# Image Options {{{ - - -# Image Source -# --image wall, ascii, /path/to/img, /path/to/dir/, off -image="wall" - -# Thumbnail directory -thumbnail_dir="$HOME/.cache/thumbnails/neofetch" - -# W3m-img path -# This is automatically detected, this variable -# should only be set to w3m-img's location if the -# builtin detection doesn't work. -w3m_img_path="/usr/lib/w3m/w3mimgdisplay" - -# Crop mode -# --crop_mode normal/fit/fill -crop_mode="normal" - -# Crop offset -# Only affects normal mode. -# --crop_offset northwest/north/northeast/west/center -# east/southwest/south/southeast -crop_offset="center" - -# Image size -# The image is half the terminal width by default. -# --size auto, 00px, 00%, none -image_size="auto" - -# Right gap between image and text -# --gap num -gap=2 - -# Image offsets -# --xoffset px -# --yoffset px -yoffset=0 -xoffset=0 - - -# }}} - -# Ascii Options {{{ - - -# Default ascii image to use -# When this is set to distro it will use your -# distro's logo as the ascii. -# --ascii 'distro', path/to/ascii -ascii="distro" - -# Ascii colors -# When this is set to distro it will use your -# ditro's colors to color the ascii. -# NOTE: You can also set this to a range of colors -# which will allow you to custom color distro logos -# --ascii_colors distro -# --ascii_colors 2 4 5 6 -ascii_colors=(distro) - -# Logo size -# Arch, Crux and Gentoo have a smaller logo -# variant. Changing the value below to 'small' -# will make neofetch use the small logo. -# --ascii_logo_size small, normal -ascii_logo_size="normal" - -# Bold ascii logo -# Whether or not to bold the ascii logo. -# --ascii_bold on/off -ascii_bold="off" - - -# }}} - -# Scrot Options {{{ - - -# Whether or not to always take a screenshot -# You can manually take a screenshot with "--scrot" or "-s" -scrot="off" - -# Screenshot program to launch -# --scrot_cmd -scrot_cmd="scrot -c -d 3" - -# Scrot dir -# Where to save the screenshots -# --scrot_dir /path/to/screenshot/folder -scrot_dir="$HOME/Pictures/" - -# Scrot filename -# What to name the screenshots -# --scrot_name str -scrot_name="neofetch-$(date +%F-%T).png" - - -# }}} - -# Stdout options {{{ - -# Separator for stdout mode -# --stdout_separator string -stdout_separator=" " - -# }}} - -# Config Options {{{ - - -# Enable/Disable config file -# --config off, none -config="on" - -# Path to custom config file location -# --config path/to/config -config_file="${XDG_CONFIG_HOME:-${HOME}/.config}/neofetch/config" - - -# }}} - - -# }}} - - # Gather Info {{{ @@ -2890,6 +2483,8 @@ trim() { # Get script directory {{{ getscriptdir () { + [ "$script_dir" ] && return + # Use $0 to get the script's physical path. cd "${0%/*}" || exit script_dir="${0##*/}" @@ -2950,6 +2545,23 @@ esac # }}} +# Source default config {{{ + +getdefaultconfig () { + if [ -f "/usr/share/neofetch/config" ]; then + source "/usr/share/neofetch/config" + + elif [ -f "/usr/local/share/neofetch/config" ]; then + source "/usr/local/share/neofetch/config" + + else + getscriptdir + source "${script_dir}/config/config" + fi +} + +# }}} + # Progress Bars {{{ bar() { @@ -3344,6 +2956,9 @@ done # Call Functions and Finish Up {{{ +# Source config file +getdefaultconfig + # Restore cursor and clear screen on ctrl+c trap 'printf "\033[?25h"; clear; exit' 2 @@ -3441,7 +3056,8 @@ fi # Show error messages if [ "$verbose" == "on" ]; then - printf "%s" "$err" + printf "%s" "${err//\\n/ +}" fi # }}} From 2c9c741329b5265ab3edfe66accb3c49e9c29c81 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 09:55:35 +1000 Subject: [PATCH 02/16] -v: Show where we sourced the default config from --- neofetch | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 69d65540..271b6a3c 100755 --- a/neofetch +++ b/neofetch @@ -2549,15 +2549,18 @@ esac getdefaultconfig () { if [ -f "/usr/share/neofetch/config" ]; then - source "/usr/share/neofetch/config" + default_config="/usr/share/neofetch/config" elif [ -f "/usr/local/share/neofetch/config" ]; then - source "/usr/local/share/neofetch/config" + default_config="/usr/local/share/neofetch/config" else getscriptdir - source "${script_dir}/config/config" + default_config="${script_dir}/config/config" fi + + source "$default_config" + err "Sourced default config ($default_config)" } # }}} From 602629b7dd1a1a13398c0be8af1db3f359c2fd99 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 10:06:53 +1000 Subject: [PATCH 03/16] Travis use verbose mode --- .travis.yml | 4 +++- neofetch | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0be80158..e60075ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,4 +11,6 @@ before_install: script: - sudo make install - - time neofetch --test --ascii --config off --ascii_distro travis + - time neofetch --test --ascii --config off --ascii_distro travis -v \ + --refresh_rate "on" --shell_version "on" --cpu_display "infobar" \ + --memory_display "infobar" --disk_display "infobar" diff --git a/neofetch b/neofetch index 271b6a3c..38b128d9 100755 --- a/neofetch +++ b/neofetch @@ -2920,12 +2920,6 @@ while [ "$1" ]; do --test) info=(title underline distro kernel uptime packages shell resolution de wm wmtheme theme icons cpu cpu_usage gpu memory font disk battery song localip publicip users birthday term termfont) - refresh_rate="on" - shell_version="on" - cpu_display="infobar" - memory_display="infobar" - disk_display="infobar" - printinfo () { if [ "$TRAVIS_OS_NAME" ]; then info linebreak From f5f56f74da53a4c118bc4ff59ac2a43f1a9fac48 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 10:07:39 +1000 Subject: [PATCH 04/16] Fix space issue with travis ascii logo --- ascii/distro/travis | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ascii/distro/travis b/ascii/distro/travis index f7a1b2a1..96f43d99 100644 --- a/ascii/distro/travis +++ b/ascii/distro/travis @@ -5,4 +5,6 @@ ${c3} | | ___ ___| |_ ${c4} | |/ _ \/ __| __| ${c5} | | __/\__ \ |_ ${c6} |_|\___||___/\__| + + " From 800870f21b3c06dd0e387aa0f3b68ff12521399d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 10:33:21 +1000 Subject: [PATCH 05/16] More travis fixes --- .travis.yml | 4 ++-- neofetch | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e60075ef..f48eb44e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,6 @@ before_install: script: - sudo make install - - time neofetch --test --ascii --config off --ascii_distro travis -v \ + - time neofetch --ascii --config off --ascii_distro travis -v \ --refresh_rate "on" --shell_version "on" --cpu_display "infobar" \ - --memory_display "infobar" --disk_display "infobar" + --memory_display "infobar" --disk_display "infobar" --test diff --git a/neofetch b/neofetch index 38b128d9..d3887867 100755 --- a/neofetch +++ b/neofetch @@ -2935,6 +2935,10 @@ while [ "$1" ]; do info linebreak printf "%b%s" "\033[$(tput lines)H" } + + # Set the test func to readonly so a config source + # doesn't overwrite it. + readonly -f printinfo ;; -v) verbose="on" ;; From a9829cf1e5b7ca3be27714d1c3b7cff11a93f824 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 10:41:52 +1000 Subject: [PATCH 06/16] Fix missing progress bars travis --- .travis.yml | 4 +--- neofetch | 6 ++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index f48eb44e..8636f9aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,6 +11,4 @@ before_install: script: - sudo make install - - time neofetch --ascii --config off --ascii_distro travis -v \ - --refresh_rate "on" --shell_version "on" --cpu_display "infobar" \ - --memory_display "infobar" --disk_display "infobar" --test + - time neofetch --ascii --config off --ascii_distro travis -v --test diff --git a/neofetch b/neofetch index d3887867..9c29fbd4 100755 --- a/neofetch +++ b/neofetch @@ -2920,6 +2920,12 @@ while [ "$1" ]; do --test) info=(title underline distro kernel uptime packages shell resolution de wm wmtheme theme icons cpu cpu_usage gpu memory font disk battery song localip publicip users birthday term termfont) + refresh_rate="on" + shell_version="on" + cpu_display="infobar" + memory_display="infobar" + disk_display="infobar" + printinfo () { if [ "$TRAVIS_OS_NAME" ]; then info linebreak From 216c18cd03f3f1ccb5024ec105b755cfd4018c54 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 10:48:10 +1000 Subject: [PATCH 07/16] Stop progress bars from being overidden --- neofetch | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 9c29fbd4..e25c8228 100755 --- a/neofetch +++ b/neofetch @@ -2920,11 +2920,11 @@ while [ "$1" ]; do --test) info=(title underline distro kernel uptime packages shell resolution de wm wmtheme theme icons cpu cpu_usage gpu memory font disk battery song localip publicip users birthday term termfont) - refresh_rate="on" - shell_version="on" - cpu_display="infobar" - memory_display="infobar" - disk_display="infobar" + readonly refresh_rate="on" + readonly shell_version="on" + readonly cpu_display="infobar" + readonly memory_display="infobar" + readonly disk_display="infobar" printinfo () { if [ "$TRAVIS_OS_NAME" ]; then From 7480d5c30d1b2c4dcd3e5d7a0e311b12195dd57b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 11:20:32 +1000 Subject: [PATCH 08/16] Source default config before we source User config --- neofetch | 70 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 33 deletions(-) diff --git a/neofetch b/neofetch index e25c8228..66c4ab3c 100755 --- a/neofetch +++ b/neofetch @@ -2480,6 +2480,14 @@ trim() { # Other {{{ +# Error {{{ + +err () { + err+="$(color 1)[!]$(color fg) $1 \n" +} + +# }}} + # Get script directory {{{ getscriptdir () { @@ -2500,6 +2508,34 @@ getscriptdir () { script_dir="$(pwd -P)" } +# }}} + +# Source default config {{{ + +getdefaultconfig () { + if [ -f "/usr/share/neofetch/config" ]; then + default_config="/usr/share/neofetch/config" + + elif [ -f "/usr/local/share/neofetch/config" ]; then + default_config="/usr/local/share/neofetch/config" + + else + getscriptdir + default_config="${script_dir}/config/config" + fi + + if [ -f "$default_config" ]; then + source "$default_config" + err "Sourced default config ($default_config)" + else + err "Default config not found, continuing..." + fi +} + +# Source config file +getdefaultconfig 2>/dev/null + + # }}} # Source Config {{{ @@ -2541,27 +2577,7 @@ case "$@" in config="off" ;; esac -[ "$config" == "on" ] && getconfig 2>/dev/null - -# }}} - -# Source default config {{{ - -getdefaultconfig () { - if [ -f "/usr/share/neofetch/config" ]; then - default_config="/usr/share/neofetch/config" - - elif [ -f "/usr/local/share/neofetch/config" ]; then - default_config="/usr/local/share/neofetch/config" - - else - getscriptdir - default_config="${script_dir}/config/config" - fi - - source "$default_config" - err "Sourced default config ($default_config)" -} +[ "${config:-on}" == "on" ] && getconfig 2>/dev/null # }}} @@ -2618,14 +2634,6 @@ kdeconfigdir () { # }}} -# Error {{{ - -err () { - err+="$(color 1)[!]$(color fg) $1 \n" -} - -# }}} - # }}} @@ -2962,10 +2970,6 @@ done # Call Functions and Finish Up {{{ - -# Source config file -getdefaultconfig - # Restore cursor and clear screen on ctrl+c trap 'printf "\033[?25h"; clear; exit' 2 From 1b336f912e8911c1efd8dd3a32d100e540f7d46c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 11:25:59 +1000 Subject: [PATCH 09/16] Added verbose messages for confog sourcing --- neofetch | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index 66c4ab3c..0ba3dd29 100755 --- a/neofetch +++ b/neofetch @@ -2540,11 +2540,11 @@ getdefaultconfig 2>/dev/null # Source Config {{{ -# Check for $config_file first getconfig () { # Check $config_file if [ -f "$config_file" ]; then source "$config_file" + err "Sourced user config ($config_file)" return fi mkdir -p "$XDG_CONFIG_HOME/neofetch/" @@ -2552,22 +2552,25 @@ getconfig () { # Check $XDG_CONFIG_HOME/neofetch and create the # dir/files if they don't exist. if [ -f "$XDG_CONFIG_HOME/neofetch/config" ]; then - source "$XDG_CONFIG_HOME/neofetch/config" + config_file="$XDG_CONFIG_HOME/neofetch/config" elif [ -f "/usr/share/neofetch/config" ]; then cp "/usr/share/neofetch/config" "$XDG_CONFIG_HOME/neofetch" - source "$XDG_CONFIG_HOME/neofetch/config" + config_file="$XDG_CONFIG_HOME/neofetch/config" elif [ -f "/usr/local/share/neofetch/config" ]; then cp "/usr/local/share/neofetch/config" "$XDG_CONFIG_HOME/neofetch" - source "$XDG_CONFIG_HOME/neofetch/config" + config_file="$XDG_CONFIG_HOME/neofetch/config" else getscriptdir cp "$script_dir/config/config" "$XDG_CONFIG_HOME/neofetch" - source "$XDG_CONFIG_HOME/neofetch/config" + config_file="$XDG_CONFIG_HOME/neofetch/config" fi + + source "$config_file" + err "Sourced user config ($config_file)" } # Check the commandline flags early for '--config none/off' From 9a31740184be31c598cd740f53fc546586a2985a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 11:38:32 +1000 Subject: [PATCH 10/16] Simplify default config --- neofetch | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 0ba3dd29..1c2b50d7 100755 --- a/neofetch +++ b/neofetch @@ -2524,8 +2524,7 @@ getdefaultconfig () { default_config="${script_dir}/config/config" fi - if [ -f "$default_config" ]; then - source "$default_config" + if source "$default_config"; then err "Sourced default config ($default_config)" else err "Default config not found, continuing..." From 56325786d2c7aef1677b1ebde3ccd62790432552 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 16:45:36 +1000 Subject: [PATCH 11/16] Simplify err --- neofetch | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 1c2b50d7..56715639 100755 --- a/neofetch +++ b/neofetch @@ -2483,7 +2483,8 @@ trim() { # Error {{{ err () { - err+="$(color 1)[!]$(color fg) $1 \n" + err+="$(color 1)[!]$(color fg) $1 +" } # }}} @@ -2581,6 +2582,7 @@ case "$@" in esac [ "${config:-on}" == "on" ] && getconfig 2>/dev/null + # }}} # Progress Bars {{{ @@ -3069,8 +3071,7 @@ fi # Show error messages if [ "$verbose" == "on" ]; then - printf "%s" "${err//\\n/ -}" + printf "%s" "$err" fi # }}} From d8a1165694c5ced74ab369ba582ca35fb70d4baf Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 16:52:51 +1000 Subject: [PATCH 12/16] Add missing ascii_distro config option --- config/config | 5 +++++ neofetch | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/config/config b/config/config index 01c20cb3..2425557e 100644 --- a/config/config +++ b/config/config @@ -345,6 +345,11 @@ xoffset=0 # --ascii 'distro', path/to/ascii ascii="distro" +# Ascii distro +# Which distro's ascii art to display. +# --ascii_distro 'auto', 'distro_name' +ascii_distro="auto" + # Ascii colors # When this is set to distro it will use your # ditro's colors to color the ascii. diff --git a/neofetch b/neofetch index 56715639..3ea4d96b 100755 --- a/neofetch +++ b/neofetch @@ -2979,7 +2979,9 @@ trap 'printf "\033[?25h"; clear; exit' 2 # Distro detection getdistro -[ -z "$ascii_distro" ] && ascii_distro="$(trim "$distro")" +case "${ascii_distro:-auto}" in + "auto") ascii_distro="$(trim "$distro")" ;; +esac # Get colors and bold bold From cb9e7fac4ced61d477297f65a54a9fb4646450ee Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 17:05:14 +1000 Subject: [PATCH 13/16] Move comment --- neofetch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 3ea4d96b..d5e2d81a 100755 --- a/neofetch +++ b/neofetch @@ -16,13 +16,13 @@ XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}" export LC_ALL=C export LANG=C -# Gather Info {{{ - - # Set no case match. shopt -s nocasematch +# Gather Info {{{ + + # Operating System {{{ case "$(uname)" in From 2511511174e185e9020b68a14460548d8014458c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 17:08:22 +1000 Subject: [PATCH 14/16] Remove stray comment --- neofetch | 1 - 1 file changed, 1 deletion(-) diff --git a/neofetch b/neofetch index d5e2d81a..68816da3 100755 --- a/neofetch +++ b/neofetch @@ -2535,7 +2535,6 @@ getdefaultconfig () { # Source config file getdefaultconfig 2>/dev/null - # }}} # Source Config {{{ From 7a774dd48d89270aaf3f9f1110e0220386bee000 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 20:36:48 +1000 Subject: [PATCH 15/16] Move the commands near the bottom of the script to a function called main --- neofetch | 177 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 92 insertions(+), 85 deletions(-) diff --git a/neofetch b/neofetch index 68816da3..1289ae45 100755 --- a/neofetch +++ b/neofetch @@ -2532,14 +2532,11 @@ getdefaultconfig () { fi } -# Source config file -getdefaultconfig 2>/dev/null - # }}} # Source Config {{{ -getconfig () { +getuserconfig () { # Check $config_file if [ -f "$config_file" ]; then source "$config_file" @@ -2579,7 +2576,9 @@ case "$@" in config="off" ;; esac -[ "${config:-on}" == "on" ] && getconfig 2>/dev/null + +getdefaultconfig 2>/dev/null +[ "${config:-on}" == "on" ] && getuserconfig 2>/dev/null # }}} @@ -2925,7 +2924,7 @@ while [ "$1" ]; do --config) case "$2" in "none" | "off") config="off" ;; - *) config_file="$2"; config="on"; getconfig 2>/dev/null ;; + *) config_file="$2"; config="on"; getuserconfig 2>/dev/null ;; esac ;; --test) @@ -2973,106 +2972,114 @@ done # Call Functions and Finish Up {{{ -# Restore cursor and clear screen on ctrl+c -trap 'printf "\033[?25h"; clear; exit' 2 +main () { + # Restore cursor and clear screen on ctrl+c + trap 'printf "\033[?25h"; clear; exit' 2 -# Distro detection -getdistro -case "${ascii_distro:-auto}" in - "auto") ascii_distro="$(trim "$distro")" ;; -esac + # If the script exits for any reason, unhide the cursor. + trap 'printf "\033[?25h"' EXIT -# Get colors and bold -bold -colors + # Distro detection + getdistro + case "${ascii_distro:-auto}" in + "auto") ascii_distro="$(trim "$distro")" ;; + esac -# If the script exits for any reason, unhide the cursor. -trap 'printf "\033[?25h"' EXIT + # Get colors and bold + bold + colors -# Clear the scren -clear + # Clear the scren + clear -# Hide the cursor -printf "\033[?25l" + # Hide the cursor + printf "\033[?25l" -if [ "$image" != "off" ]; then - # If iterm2 is detected use iterm2 backend. - if [ -n "$ITERM_PROFILE" ]; then - image_backend="iterm2" + # Images {{{ - elif [ "$(tycat 2>/dev/null)" ]; then - image_backend="tycat" + # Get the image src + if [ "$image" != "off" ]; then + # Set the image backend + if [ -n "$ITERM_PROFILE" ]; then + image_backend="iterm2" - else - image_backend="w3m" + elif [ "$(tycat 2>/dev/null)" ]; then + image_backend="tycat" + + else + image_backend="w3m" + fi + + # Find w3mimgdisplay + [ "$image_backend" == "w3m" ] && \ + [ "$image" != "ascii" ] && \ + getw3m_img_path + + # Get the image + getimage fi - # Find w3mimgdisplay - [ "$image_backend" == "w3m" ] && \ - [ "$image" != "ascii" ] && \ - getw3m_img_path + # Display the image if enabled + if [ "$image" != "off" ] && [ "$image" != "ascii" ]; then + case "$image_backend" in + "w3m") + printf "%b%s\n" "0;1;$xoffset;$yoffset;$width;$height;;;;;$img\n4;\n3;" |\ + $w3m_img_path 2>/dev/null || padding="\033[0C" + ;; - # Get the image - getimage -fi + "iterm2") + printf "%b%s\a\n" "\033]1337;File=width=${width}px;height=${height}px;inline=1:$(base64 < "$img")" + ;; -# Display the image if enabled -if [ "$image" != "off" ] && [ "$image" != "ascii" ]; then - case "$image_backend" in - "w3m") - printf "%b%s\n" "0;1;$xoffset;$yoffset;$width;$height;;;;;$img\n4;\n3;" |\ - $w3m_img_path 2>/dev/null || padding="\033[0C" - ;; + "tycat") + tycat "$img" + ;; + esac + fi - "iterm2") - printf "%b%s\a\n" "\033]1337;File=width=${width}px;height=${height}px;inline=1:$(base64 < "$img")" - ;; + # }}} - "tycat") - tycat "$img" - ;; - esac -fi + # Disable line wrap + printf "\033[?7l" -# Disable line wrap -printf "\033[?7l" + # Move cursor to the top + [ "$image" != "off" ] && printf "\033[0H" -# Move cursor to the top -[ "$image" != "off" ] && printf "\033[0H" + # Print the info + printinfo -# Print the info -printinfo + # Dynamic prompt location {{{ -# Dynamic prompt location {{{ + # Get cursor position + info_height="$(stty -echo; IFS=';' read -rdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}"; stty echo)" -# Get cursor position -info_height="$(stty -echo; IFS=';' read -rdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}"; stty echo)" + # Calculate image height in terminal cells. + # The '+ 3' adds a gap between the prompt and the content. + [ "$image" != "ascii" ] && [ "$image" != "off" ] && \ + lines="$((${height:-1} / ${font_height:-1} + 3))" -# Calculate image height in terminal cells. -# The '+ 3' adds a gap between the prompt and the content. -[ "$image" != "ascii" ] && [ "$image" != "off" ] && \ - lines="$((${height:-1} / ${font_height:-1} + 3))" + # If the info is higher than the ascii/image place the prompt + # based on the info height instead of the ascii/image height. + [ "${lines:-0}" -lt "${info_height:-0}" ] && lines="$info_height" -# If the info is higher than the ascii/image place the prompt -# based on the info height instead of the ascii/image height. -[ "${lines:-0}" -lt "${info_height:-0}" ] && lines="$info_height" + # Set the prompt location + [ "$image" != "off" ] && printf "%b%s" "\033[${lines:-0}H" -# Set the prompt location -[ "$image" != "off" ] && printf "%b%s" "\033[${lines:-0}H" - -# }}} - -# Re-enable line wrap -printf "%b%s" "\033[?7h" - -# If enabled take a screenshot -if [ "$scrot" == "on" ]; then - takescrot -fi - -# Show error messages -if [ "$verbose" == "on" ]; then - printf "%s" "$err" -fi + # }}} + + # Re-enable line wrap + printf "%b%s" "\033[?7h" + + # If enabled take a screenshot + [ "$scrot" == "on" ] && takescrot + + # Show error messages + [ "$verbose" == "on" ] && printf "%s" "$err" + + # Reset exit status of the tests above. + printf "%s" +} + +main # }}} From b3852e0f10533582a6d4522911af10eaf37d3537 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 12 Aug 2016 20:44:36 +1000 Subject: [PATCH 16/16] Changelog --- 1.8.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/1.8.md b/1.8.md index 83cddd82..7b9a0e4a 100644 --- a/1.8.md +++ b/1.8.md @@ -32,6 +32,11 @@ bottom of the window. See [#279](https://github.com/dylanaraps/neofetch/pull/279 - Removed `line_wrap` as having it set to `on` broke the output. - Minor text fixes. - Fix issue with incorrect text color when `barinfo` is set. +- Fixed various Travis.ci bugs. +- `-v` now shows where the config files were sourced from. +- Removed in-script config in favor of sourcing the default user config. +- Moved commands near the bottom of the script to a new function called `main`. +- Cleanup ### OS @@ -125,4 +130,5 @@ distro ascii files. See this wiki page that explains the syntax. [Link](https:// - Better `Ubuntu-GNOME` ascii art. **[@hashhar](https://github.com/hashhar)** - Fix a color issue with Debian's ascii logo. - Added `--ascii_distro mac` as a shorter way of using the OS X ascii. +- Added missing `$ascii_distro` config option.