From cdce44255a903301d7c2d69239713805621e3814 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 19 Oct 2019 20:29:44 +0200 Subject: [PATCH 01/19] song: add muine player --- neofetch | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/neofetch b/neofetch index 4274be07..efb6b464 100755 --- a/neofetch +++ b/neofetch @@ -457,6 +457,7 @@ disk_subtitle="mount" # mocp # mopidy # mpd +# muine # netease-cloud-music # pogo # pragha @@ -2465,6 +2466,7 @@ get_song() { "mocp" "mopidy" "mpd" + "muine" "netease-cloud-music" "plasma-browser-integration" "pogo" @@ -2579,6 +2581,13 @@ get_song() { awk -F':|,' '{if ($6 && $8 && $4) printf $6 "\n" $8 "\n" $4}')" ;; + "muine"*) + song="$(dbus-send --print-reply --dest=org.gnome.Muine /org/gnome/Muine/Player \ + org.gnome.Muine.Player.GetCurrentSong | + awk -F':' '/^artist/ {a=$2} /^album/ {b=$2} /^title/ {t=$2} + END {print a "\n" b "\n" t}')" + ;; + "quodlibet"*) song="$(dbus-send --print-reply --dest=net.sacredchao.QuodLibet \ /net/sacredchao/QuodLibet net.sacredchao.QuodLibet.CurrentSong |\ From 25896145c26e69e20f0932e5786858239053606f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 20 Oct 2019 11:43:50 +0200 Subject: [PATCH 02/19] song: add elementary music player --- neofetch | 3 +++ 1 file changed, 3 insertions(+) diff --git a/neofetch b/neofetch index efb6b464..35ce677f 100755 --- a/neofetch +++ b/neofetch @@ -451,6 +451,7 @@ disk_subtitle="mount" # gmusicbrowser # gogglesmm # guayadeque +# io.elementary.music # iTunes # juk # lollypop @@ -2460,6 +2461,7 @@ get_song() { "gmusicbrowser" "gogglesmm" "guayadeque" + "io.elementary.music" "iTunes" "juk" "lollypop" @@ -2534,6 +2536,7 @@ get_song() { "xnoise"*) get_song_dbus "xnoise" ;; "netease-cloud-music"*) get_song_dbus "netease-cloud-music" ;; "plasma-browser-integration"*) get_song_dbus "plasma-browser-integration" ;; + "io.elementary.music"*) get_song_dbus "Music" ;; "cmus"*) # NOTE: cmus >= 2.8.0 supports mpris2 From 78f788704e04478f66b0ca00bca0502e5459470d Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sun, 20 Oct 2019 17:57:32 +0200 Subject: [PATCH 03/19] Add kitty to the list of available backends --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 35ce677f..16ce10c4 100755 --- a/neofetch +++ b/neofetch @@ -4551,7 +4551,7 @@ BARS: IMAGE BACKEND: --backend backend Which image backend to use. Possible values: 'ascii', 'caca', 'chafa', 'jp2a', 'iterm2', - 'off', 'sixel', 'tycat', 'w3m' + 'off', 'sixel', 'tycat', 'w3m', 'kitty' --source source Which image or ascii file to use. Possible values: 'auto', 'ascii', 'wallpaper', '/path/to/img', '/path/to/ascii', '/path/to/dir/', 'command output' [ascii] From a9eeae8969cbdebefee15d1ec5d86511dc63b039 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Sun, 20 Oct 2019 22:04:25 +0200 Subject: [PATCH 04/19] Regenerate man page --- neofetch.1 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/neofetch.1 b/neofetch.1 index 525291a9..3db17b78 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -1,5 +1,5 @@ -.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.8. -.TH NEOFETCH "1" "August 2019" "Neofetch 6.1.0" "User Commands" +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.11. +.TH NEOFETCH "1" "October 2019" "Neofetch 6.1.0" "User Commands" .SH NAME Neofetch \- A fast, highly customizable system info script .SH SYNOPSIS @@ -40,7 +40,7 @@ For example: 'info "Memory" memory' would be '\-\-disable memory' .IP NOTE: You can supply multiple args. eg. 'neofetch \fB\-\-disable\fR cpu gpu' .TP -\fB\-\-package_managers\fR on/tiny/off +\fB\-\-package_managers\fR on/off Hide/Show Package Manager names . (on, tiny, off) .TP \fB\-\-os_arch\fR on/off @@ -79,7 +79,7 @@ NOTE: This only works on Linux and BSD. NOTE: For FreeBSD and NetBSD\-based systems, you need to enable coretemp kernel module. This only supports newer Intel processors. .TP -\fB\-\-distro_shorthand\fR on/tiny/off +\fB\-\-distro_shorthand\fR on/off Shorten the output of distro (on, tiny, off) .IP NOTE: This option won't work in Windows (Cygwin) @@ -89,7 +89,7 @@ Shorten the output of kernel .IP NOTE: This option won't work in BSDs (except PacBSD and PC\-BSD) .TP -\fB\-\-uptime_shorthand\fR on/tiny/off +\fB\-\-uptime_shorthand\fR on/off Shorten the output of uptime (on, tiny, off) .TP \fB\-\-refresh_rate\fR on/off @@ -218,7 +218,7 @@ Possible values: bar, infobar, barinfo, off \fB\-\-backend\fR backend Which image backend to use. Possible values: 'ascii', 'caca', 'chafa', 'jp2a', 'iterm2', -\&'off', 'sixel', 'tycat', 'w3m' +\&'off', 'sixel', 'tycat', 'w3m', 'kitty' .TP \fB\-\-source\fR source Which image or ascii file to use. @@ -283,7 +283,7 @@ NOTE: Change this to 'Lubuntu', 'Xubuntu', 'Ubuntu\-GNOME', \&'Ubuntu\-Studio' or 'Ubuntu\-Budgie' to use the flavors. .TP NOTE: Alpine, Arch, CRUX, Debian, Gentoo, FreeBSD, Mac, NixOS, -OpenBSD, and Void have a smaller logo variant. +OpenBSD, postmarketOS, and Void have a smaller logo variant. .IP NOTE: Use '{distro name}_small' to use the small variants. .TP @@ -339,6 +339,9 @@ Specify a path to a custom config file \fB\-\-config\fR none Launch the script without a config file .TP +\fB\-\-no_config\fR +Don't create the user config file. +.TP \fB\-\-print_config\fR Print the default config file to stdout. .TP From 5ada1e6c4e43ca122c37fa427bd24a92c28aed09 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 26 Oct 2019 21:54:37 +0200 Subject: [PATCH 05/19] ascii: fix Guix logo --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 16ce10c4..3bce1a6c 100755 --- a/neofetch +++ b/neofetch @@ -6679,7 +6679,7 @@ ${c1}|.__ __.| EOF ;; - "GuixSD"*) + "Guix"*) set_colors 3 7 6 1 8 read -rd '' ascii_data <<'EOF' ${c1} .. `. From c0d5508f0374fcc7b83f539c0981042a7649e106 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 26 Oct 2019 21:56:45 +0200 Subject: [PATCH 06/19] ascii: rename small Guix logo too --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 3bce1a6c..292093bb 100755 --- a/neofetch +++ b/neofetch @@ -6666,7 +6666,7 @@ eee ${c2}// \\ooo/ \\\ ${c1}eee EOF ;; - "guixsd_small"*) + "guix_small"*) set_colors 3 7 6 1 8 read -rd '' ascii_data <<'EOF' ${c1}|.__ __.| From 3be3b93634165918d524be6846346a83f471ce98 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 27 Oct 2019 09:30:28 +0100 Subject: [PATCH 07/19] style: fix Plasma themes --- neofetch | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 292093bb..952ab7d6 100755 --- a/neofetch +++ b/neofetch @@ -2726,7 +2726,7 @@ get_style() { # Check for DE Theme. case "$de" in - "KDE"*) + "KDE"* | "Plasma"*) kde_config_dir if [[ -f "${kde_config_dir}/kdeglobals" ]]; then @@ -2739,7 +2739,7 @@ get_style() { kde_font_size="${kde_font_size/,*}" kde_theme="${kde_theme/,*} ${kde_theme/*,} ${kde_font_size}" fi - kde_theme="$kde_theme [KDE], " + kde_theme="$kde_theme ["$de"], " else err "Theme: KDE config files not found, skipping." fi @@ -2845,6 +2845,7 @@ get_style() { theme="${theme// '[GTK'[0-9]']'}" theme="${theme/ '[GTK2/3]'}" theme="${theme/ '[KDE]'}" + theme="${theme/ '[Plasma]'}" fi fi } From 5fa7446fe05218ed81d68bafd1b414aadde3195b Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 27 Oct 2019 09:56:16 +0100 Subject: [PATCH 08/19] Remove quotes (shellcheck) --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 952ab7d6..6d1dc586 100755 --- a/neofetch +++ b/neofetch @@ -2739,7 +2739,7 @@ get_style() { kde_font_size="${kde_font_size/,*}" kde_theme="${kde_theme/,*} ${kde_theme/*,} ${kde_font_size}" fi - kde_theme="$kde_theme ["$de"], " + kde_theme="$kde_theme [$de], " else err "Theme: KDE config files not found, skipping." fi From b81b69009e318ada5bead8c4256cb6a5cb6de6e4 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 28 Oct 2019 09:00:04 +0200 Subject: [PATCH 09/19] neofetch: remove uneeded quotes --- neofetch | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/neofetch b/neofetch index 6d1dc586..93b0116f 100755 --- a/neofetch +++ b/neofetch @@ -28,12 +28,12 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -version="6.1.0" +version=6.1.0 -bash_version="${BASH_VERSION/.*}" -sys_locale="${LANG:-C}" -XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}" -PATH="${PATH}:/usr/xpg4/bin:/usr/sbin:/sbin:/usr/etc:/usr/libexec" +bash_version=${BASH_VERSION/.*} +sys_locale=${LANG:-C} +XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-${HOME}/.config} +PATH=$PATH:/usr/xpg4/bin:/usr/sbin:/sbin:/usr/etc:/usr/libexec reset='\e[0m' shopt -s nocasematch @@ -42,7 +42,7 @@ LC_ALL=C LANG=C # Fix issues with gsettings. -export GIO_EXTRA_MODULES="/usr/lib/x86_64-linux-gnu/gio/modules/" +export GIO_EXTRA_MODULES=/usr/lib/x86_64-linux-gnu/gio/modules/ # Neofetch default config. read -rd '' config <<'EOF' @@ -819,25 +819,25 @@ EOF get_os() { # $kernel_name is set in a function called cache_uname and is # just the output of "uname -s". - case "$kernel_name" in - "Darwin"): "$darwin_name" ;; - "SunOS"): "Solaris" ;; - "Haiku"): "Haiku" ;; - "MINIX"): "MINIX" ;; - "AIX"): "AIX" ;; - "IRIX"*): "IRIX" ;; - "FreeMiNT"): "FreeMiNT" ;; + case $kernel_name in + Darwin): "$darwin_name" ;; + SunOS): Solaris ;; + Haiku): Haiku ;; + MINIX): MINIX ;; + AIX): AIX ;; + IRIX*): IRIX ;; + FreeMiNT): FreeMiNT ;; - "Linux" | "GNU"*) - : "Linux" + Linux|GNU*) + : Linux ;; - *"BSD" | "DragonFly" | "Bitrig") - : "BSD" + *BSD|DragonFly|Bitrig) + : BSD ;; - "CYGWIN"* | "MSYS"* | "MINGW"*) - : "Windows" + CYGWIN*|MSYS*|MINGW*) + : Windows ;; *) @@ -846,7 +846,8 @@ get_os() { exit 1 ;; esac - os="$_" + + os=$_ } get_distro() { From c154aebc402548af2e4269d69fd7f758d7801deb Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 28 Oct 2019 09:13:17 +0200 Subject: [PATCH 10/19] neofetch: remove uneeded quotes --- neofetch | 236 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 119 insertions(+), 117 deletions(-) diff --git a/neofetch b/neofetch index 93b0116f..a1c80e6e 100755 --- a/neofetch +++ b/neofetch @@ -851,75 +851,74 @@ get_os() { } get_distro() { - [[ "$distro" ]] && return + [[ $distro ]] && return - case "$os" in - "Linux" | "BSD" | "MINIX") - if [[ -f "/bedrock/etc/bedrock-release" && "$PATH" == */bedrock/cross/* ]]; then - case "$distro_shorthand" in - "on" | "tiny") distro="Bedrock Linux" ;; - *) distro="$(< /bedrock/etc/bedrock-release)" + case $os in + Linux|BSD|MINIX) + if [[ -f /bedrock/etc/bedrock-release && $PATH == */bedrock/cross/* ]]; then + case $distro_shorthand in + on|tiny) distro="Bedrock Linux" ;; + *) distro=$(< /bedrock/etc/bedrock-release) esac - elif [[ -f "/etc/redstar-release" ]]; then - case "$distro_shorthand" in - "on" | "tiny") distro="Red Star OS" ;; + + elif [[ -f /etc/redstar-release ]]; then + case $distro_shorthand in + on|tiny) distro="Red Star OS" ;; *) distro="Red Star OS $(awk -F'[^0-9*]' '$0=$2' /etc/redstar-release)" esac - elif [[ -f "/etc/siduction-version" ]]; then - case "$distro_shorthand" in - "on" | "tiny") distro="Siduction" ;; + elif [[ -f /etc/siduction-version ]]; then + case $distro_shorthand in + on|tiny) distro=Siduction ;; *) distro="Siduction ($(lsb_release -sic))" esac + elif type -p pveversion >/dev/null; then - case "$distro_shorthand" in - "on" | "tiny") distro="Proxmox VE" ;; + case $distro_shorthand in + on|tiny) distro="Proxmox VE" ;; *) - distro="$(pveversion)" - distro="${distro#pve-manager/}" + distro=$(pveversion) + distro=${distro#pve-manager/} distro="Proxmox VE ${distro%/*}" esac elif type -p lsb_release >/dev/null; then - case "$distro_shorthand" in - "on") lsb_flags="-sir" ;; - "tiny") lsb_flags="-si" ;; - *) lsb_flags="-sd" ;; + case $distro_shorthand in + on) lsb_flags=-si ;; + tiny) lsb_flags=-si ;; + *) lsb_flags=-sd ;; esac - distro="$(lsb_release "$lsb_flags")" + distro=$(lsb_release "$lsb_flags") - elif [[ -f "/etc/os-release" || \ - -f "/usr/lib/os-release" || \ - -f "/etc/openwrt_release" || \ - -f "/etc/lsb-release" ]]; then - files=("/etc/os-release" - "/usr/lib/os-release" - "/etc/openwrt_release" - "/etc/lsb-release") + elif [[ -f /etc/os-release || \ + -f /usr/lib/os-release || \ + -f /etc/openwrt_release || \ + -f /etc/lsb-release ]]; then # Source the os-release file - for file in "${files[@]}"; do + for file in /usr/lib/os-release /etc/os-release \ + /etc/openwrt_release /etc/lsb-release; do source "$file" && break done # Format the distro name. - case "$distro_shorthand" in - "on") distro="${NAME:-${DISTRIB_ID}} ${VERSION_ID:-${DISTRIB_RELEASE}}" ;; - "tiny") distro="${NAME:-${DISTRIB_ID:-${TAILS_PRODUCT_NAME}}}" ;; - "off") distro="${PRETTY_NAME:-${DISTRIB_DESCRIPTION}} ${UBUNTU_CODENAME}" ;; + case $distro_shorthand in + on) distro="${NAME:-${DISTRIB_ID}} ${VERSION_ID:-${DISTRIB_RELEASE}}" ;; + tiny) distro="${NAME:-${DISTRIB_ID:-${TAILS_PRODUCT_NAME}}}" ;; + off) distro="${PRETTY_NAME:-${DISTRIB_DESCRIPTION}} ${UBUNTU_CODENAME}" ;; esac - elif [[ -f "/etc/GoboLinuxVersion" ]]; then - case "$distro_shorthand" in - "on" | "tiny") distro="GoboLinux" ;; + elif [[ -f /etc/GoboLinuxVersion ]]; then + case $distro_shorthand in + on|tiny) distro=GoboLinux ;; *) distro="GoboLinux $(< /etc/GoboLinuxVersion)" esac elif type -p crux >/dev/null; then - distro="$(crux)" - case "$distro_shorthand" in - "on") distro="${distro//version}" ;; - "tiny") distro="${distro//version*}" ;; + distro=$(crux) + case $distro_shorthand in + on) distro=${distro//version} ;; + tiny) distro=${distro//version*} esac elif type -p tazpkg >/dev/null; then @@ -927,90 +926,91 @@ get_distro() { elif type -p kpt >/dev/null && \ type -p kpm >/dev/null; then - distro="KSLinux" + distro=KSLinux - elif [[ -d "/system/app/" && -d "/system/priv-app" ]]; then + elif [[ -d /system/app/ && -d /system/priv-app ]]; then distro="Android $(getprop ro.build.version.release)" # Chrome OS doesn't conform to the /etc/*-release standard. # While the file is a series of variables they can't be sourced # by the shell since the values aren't quoted. - elif [[ -f "/etc/lsb-release" && "$(< /etc/lsb-release)" == *CHROMEOS* ]]; then - distro="$(awk -F '=' '/NAME|VERSION/ {printf $2 " "}' /etc/lsb-release)" + elif [[ -f /etc/lsb-release && $(< /etc/lsb-release) == *CHROMEOS* ]]; then + distro=$(awk -F '=' '/NAME|VERSION/ {printf $2 " "}' /etc/lsb-release) elif type -p guix >/dev/null; then - case "$distro_shorthand" in - "on" | "tiny") distro="Guix System" ;; + case $distro_shorthand in + on|tiny) distro="Guix System" ;; *) distro="Guix System $(guix system -V | awk 'NR==1{printf $5}')" esac else for release_file in /etc/*-release; do - distro+="$(< "$release_file")" + distro+=$(< "$release_file") done - if [[ -z "$distro" ]]; then - case "$distro_shorthand" in - "on" | "tiny") distro="$kernel_name" ;; + if [[ -z $distro ]]; then + case $distro_shorthand in + on|tiny) distro=$kernel_name ;; *) distro="$kernel_name $kernel_version" ;; esac - distro="${distro/DragonFly/DragonFlyBSD}" - # Workarounds for FreeBSD based distros. - [[ -f "/etc/pcbsd-lang" ]] && distro="PCBSD" - [[ -f "/etc/trueos-lang" ]] && distro="TrueOS" + distro=${distro/DragonFly/DragonFlyBSD} - # /etc/pacbsd-release is an empty file - [[ -f "/etc/pacbsd-release" ]] && distro="PacBSD" + # Workarounds for some BSD based distros. + [[ -f /etc/pcbsd-lang ]] && distro=PCBSD + [[ -f /etc/trueos-lang ]] && distro=TrueOS + [[ -f /etc/pacbsd-release ]] && distro=PacBSD fi fi - if [[ "$(< /proc/version)" == *Microsoft* || "$kernel_version" == *Microsoft* ]]; then - case "$distro_shorthand" in - "on") distro+=" [Windows 10]" ;; - "tiny") distro="Windows 10" ;; - *) distro+=" on Windows 10" ;; + if [[ $(< /proc/version) == *Microsoft* || $kernel_version == *Microsoft* ]]; then + case $distro_shorthand in + on) distro+=" [Windows 10]" ;; + tiny) distro="Windows 10" ;; + *) distro+=" on Windows 10" ;; esac - elif [[ "$(< /proc/version)" == *chrome-bot* || -f "/dev/cros_ec" ]]; then - case "$distro_shorthand" in - "on") distro+=" [Chrome OS]" ;; - "tiny") distro="Chrome OS" ;; - *) distro+=" on Chrome OS" ;; + elif [[ $(< /proc/version) == *chrome-bot* || -f /dev/cros_ec ]]; then + case $distro_shorthand in + on) distro+=" [Chrome OS]" ;; + tiny) distro="Chrome OS" ;; + *) distro+=" on Chrome OS" ;; esac fi - distro="$(trim_quotes "$distro")" - distro="${distro/NAME=}" + distro=$(trim_quotes "$distro") + distro=${distro/NAME=} ;; "Mac OS X") - case "$osx_version" in - "10.4"*) codename="Mac OS X Tiger" ;; - "10.5"*) codename="Mac OS X Leopard" ;; - "10.6"*) codename="Mac OS X Snow Leopard" ;; - "10.7"*) codename="Mac OS X Lion" ;; - "10.8"*) codename="OS X Mountain Lion" ;; - "10.9"*) codename="OS X Mavericks" ;; - "10.10"*) codename="OS X Yosemite" ;; - "10.11"*) codename="OS X El Capitan" ;; - "10.12"*) codename="macOS Sierra" ;; - "10.13"*) codename="macOS High Sierra" ;; - "10.14"*) codename="macOS Mojave" ;; - "10.15"*) codename="macOS Catalina" ;; - *) codename="macOS" ;; + case $osx_version in + 10.4*) codename="Mac OS X Tiger" ;; + 10.5*) codename="Mac OS X Leopard" ;; + 10.6*) codename="Mac OS X Snow Leopard" ;; + 10.7*) codename="Mac OS X Lion" ;; + 10.8*) codename="OS X Mountain Lion" ;; + 10.9*) codename="OS X Mavericks" ;; + 10.10*) codename="OS X Yosemite" ;; + 10.11*) codename="OS X El Capitan" ;; + 10.12*) codename="macOS Sierra" ;; + 10.13*) codename="macOS High Sierra" ;; + 10.14*) codename="macOS Mojave" ;; + 10.15*) codename="macOS Catalina" ;; + *) codename=macOS ;; esac + distro="$codename $osx_version $osx_build" - case "$distro_shorthand" in - "on") distro="${distro/ ${osx_build}}" ;; - "tiny") - case "$osx_version" in - "10."[4-7]*) distro="${distro/${codename}/Mac OS X}" ;; - "10."[8-9]* | "10.1"[0-1]*) distro="${distro/${codename}/OS X}" ;; - "10.1"[2-4]*) distro="${distro/${codename}/macOS}" ;; + case $distro_shorthand in + on) distro=${distro/ ${osx_build}} ;; + + tiny) + case $osx_version in + 10.[4-7]*) distro=${distro/${codename}/Mac OS X} ;; + 10.[8-9]*|10.1[0-1]*) distro=${distro/${codename}/OS X} ;; + 10.1[2-4]*) distro=${distro/${codename}/macOS} ;; esac - distro="${distro/ ${osx_build}}" + distro=${distro/ ${osx_build}} ;; esac ;; @@ -1018,57 +1018,59 @@ get_distro() { "iPhone OS") distro="iOS $osx_version" - # "uname -m" doesn't print architecture on iOS so we force it off. - os_arch="off" + # "uname -m" doesn't print architecture on iOS. + os_arch=off ;; - "Windows") - distro="$(wmic os get Caption)" - distro="${distro/Caption}" - distro="${distro/Microsoft }" + Windows) + distro=$(wmic os get Caption) + distro=${distro/Caption} + distro=${distro/Microsoft } ;; - "Solaris") - case "$distro_shorthand" in - "on" | "tiny") distro="$(awk 'NR==1 {print $1,$3}' /etc/release)" ;; - *) distro="$(awk 'NR==1 {print $1,$2,$3}' /etc/release)" ;; + Solaris) + case $distro_shorthand in + on|tiny) distro=$(awk 'NR==1 {print $1,$3}' /etc/release) ;; + *) distro=$(awk 'NR==1 {print $1,$2,$3}' /etc/release) ;; esac - distro="${distro/\(*}" + distro=${distro/\(*} ;; - "Haiku") + Haiku) distro=Haiku ;; - "AIX") + AIX) distro="AIX $(oslevel)" ;; - "IRIX") + IRIX) distro="IRIX ${kernel_version}" ;; - "FreeMiNT") - distro="FreeMiNT" + FreeMiNT) + distro=FreeMiNT ;; esac - distro="${distro//Enterprise Server}" + distro=${distro//Enterprise Server} - [[ -z "$distro" ]] && distro="$os (Unknown)" + [[ $distro ]] || distro="$os (Unknown)" # Get OS architecture. - case "$os" in - "Solaris" | "AIX" | "Haiku" | "IRIX" | "FreeMiNT") - machine_arch="$(uname -p)" ;; - *) machine_arch="$kernel_machine" ;; + case $os in + Solaris|AIX|Haiku|IRIX|FreeMiNT) + machine_arch=$(uname -p) + ;; + + *) machine_arch=$kernel_machine ;; esac - [[ "$os_arch" == "on" ]] && \ + [[ $os_arch == on ]] && \ distro+=" $machine_arch" - [[ "${ascii_distro:-auto}" == "auto" ]] && \ - ascii_distro="$(trim "$distro")" + [[ ${ascii_distro:-auto} == auto ]] && \ + ascii_distro=$(trim "$distro") } get_model() { From 85f7b7852a60bbcdc9976d3ce4d98781c262ba5c Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 28 Oct 2019 09:28:23 +0200 Subject: [PATCH 11/19] neofetch: remove uneeded quotes --- neofetch | 303 +++++++++++++++++++++++++++---------------------------- 1 file changed, 151 insertions(+), 152 deletions(-) diff --git a/neofetch b/neofetch index a1c80e6e..fe431be5 100755 --- a/neofetch +++ b/neofetch @@ -1074,239 +1074,238 @@ get_distro() { } get_model() { - case "$os" in - "Linux") - if [[ -d "/system/app/" && -d "/system/priv-app" ]]; then + case $os in + Linux) + if [[ -d /system/app/ && -d /system/priv-app ]]; then model="$(getprop ro.product.brand) $(getprop ro.product.model)" - elif [[ -f "/sys/devices/virtual/dmi/id/product_name" || - -f "/sys/devices/virtual/dmi/id/product_version" ]]; then - model="$(< /sys/devices/virtual/dmi/id/product_name)" + elif [[ -f /sys/devices/virtual/dmi/id/product_name || + -f /sys/devices/virtual/dmi/id/product_version ]]; then + model=$(< /sys/devices/virtual/dmi/id/product_name) model+=" $(< /sys/devices/virtual/dmi/id/product_version)" - elif [[ -f "/sys/firmware/devicetree/base/model" ]]; then - model="$(< /sys/firmware/devicetree/base/model)" + elif [[ -f /sys/firmware/devicetree/base/model ]]; then + model=$(< /sys/firmware/devicetree/base/model) - elif [[ -f "/tmp/sysinfo/model" ]]; then - model="$(< /tmp/sysinfo/model)" + elif [[ -f /tmp/sysinfo/model ]]; then + model=$(< /tmp/sysinfo/model) fi ;; "Mac OS X") - if [[ "$(kextstat | grep -F -e "FakeSMC" -e "VirtualSMC")" != "" ]]; then + if [[ $(kextstat | grep -F -e "FakeSMC" -e "VirtualSMC") != "" ]]; then model="Hackintosh (SMBIOS: $(sysctl -n hw.model))" else - model="$(sysctl -n hw.model)" + model=$(sysctl -n hw.model) fi ;; "iPhone OS") - case "$kernel_machine" in - "iPad1,1"): "iPad" ;; - "iPad2,"[1-4]): "iPad 2" ;; - "iPad3,"[1-3]): "iPad 3" ;; - "iPad3,"[4-6]): "iPad 4" ;; - "iPad6,1"[12]): "iPad 5" ;; - "iPad7,"[5-6]): "iPad 6" ;; - "iPad4,"[1-3]): "iPad Air" ;; - "iPad5,"[3-4]): "iPad Air 2" ;; - "iPad11,"[3-4]): "iPad Air 3" ;; - "iPad6,"[7-8]): "iPad Pro (12.9 Inch)" ;; - "iPad6,"[3-4]): "iPad Pro (9.7 Inch)" ;; - "iPad7,"[1-2]): "iPad Pro 2 (12.9 Inch)" ;; - "iPad7,"[3-4]): "iPad Pro (10.5 Inch)" ;; - "iPad8,"[1-4]): "iPad Pro (11 Inch)" ;; - "iPad8,"[5-8]): "iPad Pro 3 (12.9 Inch)" ;; - "iPad2,"[5-7]): "iPad mini" ;; - "iPad4,"[4-6]): "iPad mini 2" ;; - "iPad4,"[7-9]): "iPad mini 3" ;; - "iPad5,"[1-2]): "iPad mini 4" ;; - "iPad11,"[1-2]): "iPad mini 5" ;; + case $kernel_machine in + iPad1,1): "iPad" ;; + iPad2,[1-4]): "iPad 2" ;; + iPad3,[1-3]): "iPad 3" ;; + iPad3,[4-6]): "iPad 4" ;; + iPad6,1[12]): "iPad 5" ;; + iPad7,[5-6]): "iPad 6" ;; + iPad4,[1-3]): "iPad Air" ;; + iPad5,[3-4]): "iPad Air 2" ;; + iPad11,[3-4]): "iPad Air 3" ;; + iPad6,[7-8]): "iPad Pro (12.9 Inch)" ;; + iPad6,[3-4]): "iPad Pro (9.7 Inch)" ;; + iPad7,[1-2]): "iPad Pro 2 (12.9 Inch)" ;; + iPad7,[3-4]): "iPad Pro (10.5 Inch)" ;; + iPad8,[1-4]): "iPad Pro (11 Inch)" ;; + iPad8,[5-8]): "iPad Pro 3 (12.9 Inch)" ;; + iPad2,[5-7]): "iPad mini" ;; + iPad4,[4-6]): "iPad mini 2" ;; + iPad4,[7-9]): "iPad mini 3" ;; + iPad5,[1-2]): "iPad mini 4" ;; + iPad11,[1-2]): "iPad mini 5" ;; - "iPhone1,1"): "iPhone" ;; - "iPhone1,2"): "iPhone 3G" ;; - "iPhone2,1"): "iPhone 3GS" ;; - "iPhone3,"[1-3]): "iPhone 4" ;; - "iPhone4,1"): "iPhone 4S" ;; - "iPhone5,"[1-2]): "iPhone 5" ;; - "iPhone5,"[3-4]): "iPhone 5c" ;; - "iPhone6,"[1-2]): "iPhone 5s" ;; - "iPhone7,2"): "iPhone 6" ;; - "iPhone7,1"): "iPhone 6 Plus" ;; - "iPhone8,1"): "iPhone 6s" ;; - "iPhone8,2"): "iPhone 6s Plus" ;; - "iPhone8,4"): "iPhone SE" ;; - "iPhone9,"[13]): "iPhone 7" ;; - "iPhone9,"[24]): "iPhone 7 Plus" ;; - "iPhone10,"[14]): "iPhone 8" ;; - "iPhone10,"[25]): "iPhone 8 Plus" ;; - "iPhone10,"[36]): "iPhone X" ;; - "iPhone11,2"): "iPhone XS" ;; - "iPhone11,"[46]): "iPhone XS Max" ;; - "iPhone11,8"): "iPhone XR" ;; + iPhone1,1): "iPhone" ;; + iPhone1,2): "iPhone 3G" ;; + iPhone2,1): "iPhone 3GS" ;; + iPhone3,[1-3]): "iPhone 4" ;; + iPhone4,1): "iPhone 4S" ;; + iPhone5,[1-2]): "iPhone 5" ;; + iPhone5,[3-4]): "iPhone 5c" ;; + iPhone6,[1-2]): "iPhone 5s" ;; + iPhone7,2): "iPhone 6" ;; + iPhone7,1): "iPhone 6 Plus" ;; + iPhone8,1): "iPhone 6s" ;; + iPhone8,2): "iPhone 6s Plus" ;; + iPhone8,4): "iPhone SE" ;; + iPhone9,[13]): "iPhone 7" ;; + iPhone9,[24]): "iPhone 7 Plus" ;; + iPhone10,[14]): "iPhone 8" ;; + iPhone10,[25]): "iPhone 8 Plus" ;; + iPhone10,[36]): "iPhone X" ;; + iPhone11,2): "iPhone XS" ;; + iPhone11,[46]): "iPhone XS Max" ;; + iPhone11,8): "iPhone XR" ;; - "iPod1,1"): "iPod touch" ;; - "ipod2,1"): "iPod touch 2G" ;; - "ipod3,1"): "iPod touch 3G" ;; - "ipod4,1"): "iPod touch 4G" ;; - "ipod5,1"): "iPod touch 5G" ;; - "ipod7,1"): "iPod touch 6G" ;; + iPod1,1): "iPod touch" ;; + ipod2,1): "iPod touch 2G" ;; + ipod3,1): "iPod touch 3G" ;; + ipod4,1): "iPod touch 4G" ;; + ipod5,1): "iPod touch 5G" ;; + ipod7,1): "iPod touch 6G" ;; esac - model="$_" + + model=$_ ;; - "BSD" | "MINIX") - model="$(sysctl -n hw.vendor hw.product)" + BSD|MINIX) + model=$(sysctl -n hw.vendor hw.product) ;; - "Windows") - model="$(wmic computersystem get manufacturer,model)" - model="${model/Manufacturer}" - model="${model/Model}" + Windows) + model=$(wmic computersystem get manufacturer,model) + model=${model/Manufacturer} + model=${model/Model} ;; - "Solaris") - model="$(prtconf -b | awk -F':' '/banner-name/ {printf $2}')" + Solaris) + model=$(prtconf -b | awk -F':' '/banner-name/ {printf $2}') ;; - "AIX") - model="$(/usr/bin/uname -M)" + AIX) + model=$(/usr/bin/uname -M) ;; - "FreeMiNT") - model="$(sysctl -n hw.model)" + FreeMiNT) + model=$(sysctl -n hw.model) ;; esac # Remove dummy OEM info. - model="${model//To be filled by O.E.M.}" - model="${model//To Be Filled*}" - model="${model//OEM*}" - model="${model//Not Applicable}" - model="${model//System Product Name}" - model="${model//System Version}" - model="${model//Undefined}" - model="${model//Default string}" - model="${model//Not Specified}" - model="${model//Type1ProductConfigId}" - model="${model//INVALID}" - model="${model//�}" + model=${model//To be filled by O.E.M.} + model=${model//To Be Filled*} + model=${model//OEM*} + model=${model//Not Applicable} + model=${model//System Product Name} + model=${model//System Version} + model=${model//Undefined} + model=${model//Default string} + model=${model//Not Specified} + model=${model//Type1ProductConfigId} + model=${model//INVALID} + model=${model//�} - case "$model" in + case $model in "Standard PC"*) model="KVM/QEMU (${model})" ;; "OpenBSD"*) model="vmm ($model)" ;; esac } get_title() { - user="${USER:-$(whoami || printf "%s" "${HOME/*\/}")}" - hostname="${HOSTNAME:-$(hostname)}" - title="${title_color}${bold}${user}${at_color}@${title_color}${bold}${hostname}" - length="$((${#user} + ${#hostname} + 1))" + user=${USER:-$(id -un || printf %s "${HOME/*\/}")} + hostname=${HOSTNAME:-$(hostname)} + title=${title_color}${bold}${user}${at_color}@${title_color}${bold}${hostname} + length=$((${#user} + ${#hostname} + 1)) } get_kernel() { # Since these OS are integrated systems, it's better to skip this function altogether - [[ "$os" =~ (AIX|IRIX) ]] && return + [[ $os =~ (AIX|IRIX) ]] && return # Haiku uses 'uname -v' and not - 'uname -r'. - [[ "$os" == Haiku ]] && { + [[ $os == Haiku ]] && { kernel=$(uname -v) return } - case "$kernel_shorthand" in - "on") kernel="$kernel_version" ;; - "off") kernel="$kernel_name $kernel_version" ;; + case $kernel_shorthand in + on) kernel=$kernel_version ;; + off) kernel="$kernel_name $kernel_version" ;; esac # Hide kernel info if it's identical to the distro info. - if [[ "$os" =~ (BSD|MINIX) && "$distro" == *"$kernel_name"* ]]; then - case "$distro_shorthand" in - "on" | "tiny") kernel="$kernel_version" ;; - *) unset kernel ;; + [[ $os =~ (BSD|MINIX) && $distro == *"$kernel_name"* ]] && + case $distro_shorthand in + on|tiny) kernel=$kernel_version ;; + *) unset kernel ;; esac - fi } get_uptime() { # Get uptime in seconds. - case "$os" in - "Linux" | "Windows" | "MINIX") + case $os in + Linux|Windows|MINIX) if [[ -r /proc/uptime ]]; then - seconds="$(< /proc/uptime)" - seconds="${seconds/.*}" + s=$(< /proc/uptime) + s=${s/.*} else - boot="$(date -d"$(uptime -s)" +%s)" - now="$(date +%s)" - seconds="$((now - boot))" + boot=$(date -d"$(uptime -s)" +%s) + now=$(date +%s) + s=$((now - boot)) fi ;; - "Mac OS X" | "iPhone OS" | "BSD" | "FreeMiNT") - boot="$(sysctl -n kern.boottime)" - boot="${boot/\{ sec = }" - boot="${boot/,*}" + "Mac OS X"|"iPhone OS"|BSD|FreeMiNT) + boot=$(sysctl -n kern.boottime) + boot=${boot/\{ sec = } + boot=${boot/,*} # Get current date in seconds. - now="$(date +%s)" - seconds="$((now - boot))" + now=$(date +%s) + s=$((now - boot)) ;; - "Solaris") - seconds="$(kstat -p unix:0:system_misc:snaptime | awk '{print $2}')" - seconds="${seconds/.*}" + Solaris) + s=$(kstat -p unix:0:system_misc:snaptime | awk '{print $2}') + s=${s/.*} ;; - "AIX" | "IRIX") - t="$(LC_ALL=POSIX ps -o etime= -p 1)" - d="0" h="0" - case "$t" in *"-"*) d="${t%%-*}"; t="${t#*-}";; esac - case "$t" in *":"*":"*) h="${t%%:*}"; t="${t#*:}";; esac - h="${h#0}" t="${t#0}" - seconds="$((d*86400 + h*3600 + ${t%%:*}*60 + ${t#*:}))" + AIX|IRIX) + t=$(LC_ALL=POSIX ps -o etime= -p 1) + + [[ $t == *-* ]] && { d=${t%%-*}; t=${t#*-}; } + [[ $t == *:*:* ]] && { h=${t%%:*}; t=${t#*:}; } + + h=${h#0} + t=${t#0} + + s=$((${d:-0}*86400 + ${h:-0}*3600 + ${t%%:*}*60 + ${t#*:})) ;; - "Haiku") - seconds=$(($(system_time) / 1000000)) + Haiku) + s=$(($(system_time) / 1000000)) ;; esac - days="$((seconds / 60 / 60 / 24)) days" - hours="$((seconds / 60 / 60 % 24)) hours" - mins="$((seconds / 60 % 60)) minutes" + d="$((s / 60 / 60 / 24)) days" + h="$((s / 60 / 60 % 24)) hours" + m="$((s / 60 % 60)) mins" # Remove plural if < 2. - ((${days/ *} == 1)) && days="${days/s}" - ((${hours/ *} == 1)) && hours="${hours/s}" - ((${mins/ *} == 1)) && mins="${mins/s}" + ((${d/ *} == 1)) && d=${d/s} + ((${h/ *} == 1)) && h=${h/s} + ((${m/ *} == 1)) && m=${m/s} # Hide empty fields. - ((${days/ *} == 0)) && unset days - ((${hours/ *} == 0)) && unset hours - ((${mins/ *} == 0)) && unset mins + ((${d/ *} == 0)) && unset days + ((${h/ *} == 0)) && unset hours + ((${m/ *} == 0)) && unset mins - uptime="${days:+$days, }${hours:+$hours, }${mins}" - uptime="${uptime%', '}" - uptime="${uptime:-${seconds} seconds}" + uptime=${d:+$d, }${h:+$h, }$m + uptime=${uptime%', '} + uptime=${uptime:-$seconds secs} # Make the output of uptime smaller. - case "$uptime_shorthand" in - "on") - uptime="${uptime/minutes/mins}" - uptime="${uptime/minute/min}" - uptime="${uptime/seconds/secs}" - ;; + case $uptime_shorthand in + on) ;; - "tiny") - uptime="${uptime/ days/d}" - uptime="${uptime/ day/d}" - uptime="${uptime/ hours/h}" - uptime="${uptime/ hour/h}" - uptime="${uptime/ minutes/m}" - uptime="${uptime/ minute/m}" - uptime="${uptime/ seconds/s}" - uptime="${uptime//,}" + tiny) + uptime=${uptime/ days/d} + uptime=${uptime/ day/d} + uptime=${uptime/ hours/h} + uptime=${uptime/ hour/h} + uptime=${uptime/ mins/m} + uptime=${uptime/ min/m} + uptime=${uptime/ secs/s} + uptime=${uptime//,} ;; esac } From 93600efc6ae07fec1f8ea32cca1a863db3b357d9 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 28 Oct 2019 09:40:04 +0200 Subject: [PATCH 12/19] neofetch: remove uneeded quotes --- neofetch | 282 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 143 insertions(+), 139 deletions(-) diff --git a/neofetch b/neofetch index fe431be5..be6ddcbe 100755 --- a/neofetch +++ b/neofetch @@ -1315,13 +1315,13 @@ get_packages() { # dir: Count files or dirs in a glob. # pac: If packages > 0, log package manager name. # tot: Count lines in command output. - has() { type -p "$1" >/dev/null && manager="$_"; } + has() { type -p "$1" >/dev/null && manager=$_; } dir() { ((packages+=$#)); pac "$#"; } pac() { (($1 > 0)) && { managers+=("$1 (${manager})"); manager_string+="${manager}, "; }; } tot() { IFS=$'\n' read -d "" -ra pkgs <<< "$("$@")";((packages+=${#pkgs[@]}));pac "${#pkgs[@]}";} # Redefine tot() for Bedrock Linux. - [[ -f "/bedrock/etc/bedrock-release" && "$PATH" == */bedrock/cross/* ]] && { + [[ -f /bedrock/etc/bedrock-release && $PATH == */bedrock/cross/* ]] && { tot() { IFS=$'\n' read -d "" -ra pkgs <<< "$(for s in $(brl list); do strat -r "$s" "$@"; done)" ((packages+="${#pkgs[@]}")) @@ -1330,25 +1330,25 @@ get_packages() { br_prefix="/bedrock/strata/*" } - case "$os" in - "Linux" | "BSD" | "iPhone OS" | "Solaris") + case $os in + Linux|BSD|"iPhone OS"|Solaris) # Package Manager Programs. - has "kiss" && tot kiss l - has "pacman-key" && tot pacman -Qq --color never - has "dpkg" && tot dpkg-query -f '.\n' -W - has "rpm" && tot rpm -qa - has "xbps-query" && tot xbps-query -l - has "apk" && tot apk info - has "opkg" && tot opkg list-installed - has "pacman-g2" && tot pacman-g2 -Q - has "lvu" && tot lvu installed - has "tce-status" && tot tce-status -i - has "pkg_info" && tot pkg_info - has "tazpkg" && tot tazpkg list && ((packages-=6)) - has "sorcery" && tot gaze installed - has "alps" && tot alps showinstalled - has "butch" && tot butch list - has "bonsai" && tot bonsai list + has kiss && tot kiss l + has pacman-key && tot pacman -Qq --color never + has dpkg && tot dpkg-query -f '.\n' -W + has rpm && tot rpm -qa + has xbps-query && tot xbps-query -l + has apk && tot apk info + has opkg && tot opkg list-installed + has pacman-g2 && tot pacman-g2 -Q + has lvu && tot lvu installed + has tce-status && tot tce-status -i + has pkg_info && tot pkg_info + has tazpkg && tot tazpkg list && ((packages-=6)) + has sorcery && tot gaze installed + has alps && tot alps showinstalled + has butch && tot butch list + has bonsai && tot bonsai list # Counting files/dirs. # Variables need to be unquoted here. Only Bedrock Linux is affected. @@ -1356,92 +1356,93 @@ get_packages() { # shellcheck disable=SC2086 { shopt -s nullglob - has "brew" && dir "$(brew --cellar)"/* - has "emerge" && dir ${br_prefix}/var/db/pkg/*/*/ - has "Compile" && dir ${br_prefix}/Programs/*/ - has "eopkg" && dir ${br_prefix}/var/lib/eopkg/package/* - has "crew" && dir ${br_prefix}/usr/local/etc/crew/meta/*.filelist - has "pkgtool" && dir ${br_prefix}/var/log/packages/* - has "kagami" && dir ${br_prefix}/var/lib/kagami/pkgs/* - has "cave" && dir ${br_prefix}/var/db/paludis/repositories/cross-installed/*/data/*/ \ - ${br_prefix}/var/db/paludis/repositories/installed/data/*/ + has brew && dir "$(brew --cellar)"/* + has emerge && dir ${br_prefix}/var/db/pkg/*/*/ + has Compile && dir ${br_prefix}/Programs/*/ + has eopkg && dir ${br_prefix}/var/lib/eopkg/package/* + has crew && dir ${br_prefix}/usr/local/etc/crew/meta/*.filelist + has pkgtool && dir ${br_prefix}/var/log/packages/* + has kagami && dir ${br_prefix}/var/lib/kagami/pkgs/* + has cave && dir ${br_prefix}/var/db/paludis/repositories/cross-installed/*/data/*/ \ + ${br_prefix}/var/db/paludis/repositories/installed/data/*/ shopt -u nullglob } # Other (Needs complex command) - has "kpm-pkg" && ((packages+="$(kpm --get-selections | grep -cv deinstall$)")) + has kpm-pkg && ((packages+=$(kpm --get-selections | grep -cv deinstall$))) - if has "guix"; then - manager="guix-system" && tot guix package -p "/run/current-system/profile" -I - manager="guix-user" && tot guix package -I - fi + has guix && { + manager=guix-system && tot guix package -p "/run/current-system/profile" -I + manager=guix-user && tot guix package -I + } - if has "nix-store"; then - manager="nix-system" && tot nix-store -q --requisites "/run/current-system/sw" - manager="nix-user" && tot nix-store -q --requisites "$HOME/.nix-profile" - fi + has nix-store && { + manager=nix-system && tot nix-store -q --requisites "/run/current-system/sw" + manager=nix-user && tot nix-store -q --requisites "$HOME/.nix-profile" + } # pkginfo is also the name of a python package manager which is painfully slow. # TODO: Fix this somehow. has pkginfo && tot pkginfo -i - case "$kernel_name" in - "FreeBSD"|"DragonFly") has "pkg" && tot pkg info ;; + case $kernel_name in + FreeBSD|DragonFly) has pkg && tot pkg info ;; + *) - has "pkg" && dir /var/db/pkg/* + has pkg && dir /var/db/pkg/* ((packages == 0)) && \ - has "pkg" && tot pkg list + has pkg && tot pkg list ;; esac # List these last as they accompany regular package managers. - has "flatpak" && tot flatpak list - has "spm" && tot spm list -i - has "puyo" && dir ~/.puyo/installed + has flatpak && tot flatpak list + has spm && tot spm list -i + has puyo && dir ~/.puyo/installed # Snap hangs if the command is run without the daemon running. # Only run snap if the daemon is also running. - has "snap" && ps -e | grep -qFm 1 "snapd" >/dev/null && tot snap list && ((packages-=1)) + has snap && ps -e | grep -qFm 1 snapd >/dev/null && tot snap list && ((packages-=1)) ;; - "Mac OS X" | "MINIX") - has "port" && tot port installed && ((packages-=1)) - has "brew" && dir /usr/local/Cellar/* - has "pkgin" && tot pkgin list + "Mac OS X"|MINIX) + has port && tot port installed && ((packages-=1)) + has brew && dir /usr/local/Cellar/* + has pkgin && tot pkgin list - if has "nix-store"; then - manager="nix-system" && tot nix-store -q --requisites "/run/current-system/sw" - manager="nix-user" && tot nix-store -q --requisites "$HOME/.nix-profile" - fi + has nix-store && { + manager=nix-system && tot nix-store -q --requisites "/run/current-system/sw" + manager=nix-user && tot nix-store -q --requisites "$HOME/.nix-profile" + } ;; - "AIX"| "FreeMiNT") - has "lslpp" && ((packages+="$(lslpp -J -l -q | grep -cv '^#')")) - has "rpm" && tot rpm -qa + AIX|FreeMiNT) + has lslpp && ((packages+=$(lslpp -J -l -q | grep -cv '^#'))) + has rpm && tot rpm -qa ;; - "Windows") - case "$kernel_name" in - "CYGWIN"*) has "cygcheck" && tot cygcheck -cd ;; - "MSYS"*) has "pacman" && tot pacman -Qq --color never ;; + Windows) + case $kernel_name in + CYGWIN*) has cygcheck && tot cygcheck -cd ;; + MSYS*) has pacman && tot pacman -Qq --color never ;; esac # Scoop environment throws errors if `tot scoop list` is used - has "scoop" && dir ~/scoop/apps/* && ((packages-=1)) + has scoop && dir ~/scoop/apps/* && ((packages-=1)) # Count chocolatey packages. - [[ -d "/cygdrive/c/ProgramData/chocolatey/lib" ]] && \ + [[ -d /cygdrive/c/ProgramData/chocolatey/lib ]] && \ dir /cygdrive/c/ProgramData/chocolatey/lib/* ;; - "Haiku") - has "pkgman" && dir /boot/system/package-links/* + Haiku) + has pkgman && dir /boot/system/package-links/* packages=${packages/pkgman/depot} ;; - "IRIX") - manager="swpkg" + IRIX) + manager=swpkg tot versions -b && ((packages-=3)) ;; esac @@ -1449,131 +1450,134 @@ get_packages() { if ((packages == 0)); then unset packages - elif [[ "$package_managers" == "on" ]]; then + elif [[ $package_managers == on ]]; then printf -v packages '%s, ' "${managers[@]}" - packages="${packages%,*}" + packages=${packages%,*} - elif [[ "$package_managers" == "tiny" ]]; then + elif [[ $package_managers == tiny ]]; then packages+=" (${manager_string%,*})" fi - packages="${packages/pacman-key/pacman}" + packages=${packages/pacman-key/pacman} } get_shell() { - case "$shell_path" in - "on") shell="$SHELL " ;; - "off") shell="${SHELL##*/} " ;; + case $shell_path in + on) shell="$SHELL " ;; + off) shell="${SHELL##*/} " ;; esac - if [[ "$shell_version" == "on" ]]; then - case "${shell_name:=${SHELL##*/}}" in - "bash") shell+="${BASH_VERSION/-*}" ;; - "sh" | "ash" | "dash") ;; + [[ $shell_version != on ]] && return - *"ksh") - shell+="$("$SHELL" -c "printf %s \"\$KSH_VERSION\"")" - shell="${shell/ * KSH}" - shell="${shell/version}" - ;; + case ${shell_name:=${SHELL##*/}} in + bash) shell+=${BASH_VERSION/-*} ;; - "tcsh") - shell+="$("$SHELL" -c "printf %s \$tcsh")" - ;; + sh|ash|dash) ;; - *) - shell+="$("$SHELL" --version 2>&1)" - shell="${shell/ "${shell_name}"}" - ;; - esac + *ksh) + shell+=$("$SHELL" -c "printf %s \"\$KSH_VERSION\"") + shell=${shell/ * KSH} + shell=${shell/version} + ;; - # Remove unwanted info. - shell="${shell/, version}" - shell="${shell/xonsh\//xonsh }" - shell="${shell/options*}" - shell="${shell/\(*\)}" - fi + tcsh) + shell+=$("$SHELL" -c "printf %s \$tcsh") + ;; + + *) + shell+=$("$SHELL" --version 2>&1) + shell=${shell/ $shell_name} + ;; + esac + + # Remove unwanted info. + shell=${shell/, version} + shell=${shell/xonsh\//xonsh } + shell=${shell/options*} + shell=${shell/\(*\)} } get_de() { # If function was run, stop here. ((de_run == 1)) && return - case "$os" in - "Mac OS X") de="Aqua" ;; - "Windows") - case "$distro" in - "Windows 8"* | "Windows 10"*) de="Modern UI/Metro" ;; - *) de="Aero" ;; + case $os in + "Mac OS X") de=Aqua ;; + + Windows) + case $distro in + "Windows 8"*|"Windows 10"*) de="Modern UI/Metro" ;; + *) de=Aero esac ;; - "FreeMiNT") + FreeMiNT) freemint_wm=(/proc/*) - case "${freemint_wm[*]}" in - *thing*) de="Thing" ;; - *jinnee*) de="Jinnee" ;; - *tera*) de="Teradesk" ;; - *neod*) de="NeoDesk" ;; - *zdesk*) de="zDesk" ;; - *mdesk*) de="mDesk" ;; + + case ${freemint_wm[*]} in + *thing*) de=Thing ;; + *jinnee*) de=Jinnee ;; + *tera*) de=Teradesk ;; + *neod*) de=NeoDesk ;; + *zdesk*) de=zDesk ;; + *mdesk*) de=mDesk ;; esac ;; *) ((wm_run != 1)) && get_wm - if [[ "$XDG_CURRENT_DESKTOP" ]]; then - de="${XDG_CURRENT_DESKTOP/X\-}" - de="${de/Budgie:GNOME/Budgie}" - de="${de/:Unity7:ubuntu}" + if [[ $XDG_CURRENT_DESKTOP ]]; then + de=${XDG_CURRENT_DESKTOP/X\-} + de=${de/Budgie:GNOME/Budgie} + de=${de/:Unity7:ubuntu} - elif [[ "$DESKTOP_SESSION" ]]; then - de="${DESKTOP_SESSION##*/}" + elif [[ $DESKTOP_SESSION ]]; then + de=${DESKTOP_SESSION##*/} - elif [[ "$GNOME_DESKTOP_SESSION_ID" ]]; then - de="GNOME" + elif [[ $GNOME_DESKTOP_SESSION_ID ]]; then + de=GNOME - elif [[ "$MATE_DESKTOP_SESSION_ID" ]]; then - de="MATE" + elif [[ $MATE_DESKTOP_SESSION_ID ]]; then + de=MATE - elif [[ "$TDE_FULL_SESSION" ]]; then - de="Trinity" + elif [[ $TDE_FULL_SESSION ]]; then + de=Trinity fi # When a window manager is started from a display manager # the desktop variables are sometimes also set to the # window manager name. This checks to see if WM == DE # and dicards the DE value. - [[ "$de" == "$wm" ]] && { unset -v de; return; } + [[ $de == "$wm" ]] && { unset -v de; return; } ;; esac # Fallback to using xprop. - [[ "$DISPLAY" && -z "$de" ]] && type -p xprop &>/dev/null && \ - de="$(xprop -root | awk '/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5/')" + [[ $DISPLAY && -z $de ]] && type -p xprop &>/dev/null && \ + de=$(xprop -root | awk '/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5/') # Format strings. - case "$de" in - "KDE_SESSION_VERSION"*) de="KDE${de/* = }" ;; - *"xfce4"*) de="Xfce4" ;; - *"xfce5"*) de="Xfce5" ;; - *"xfce"*) de="Xfce" ;; - *"mate"*) de="MATE" ;; + case $de in + KDE_SESSION_VERSION*) de=KDE${de/* = } ;; + *xfce4*) de=Xfce4 ;; + *xfce5*) de=Xfce5 ;; + *xfce*) de=Xfce ;; + *mate*) de=MATE ;; - *"MUFFIN"* | "Cinnamon") - de="$(cinnamon --version)"; de="${de:-Cinnamon}" + *MUFFIN*|Cinnamon) + de=$(cinnamon --version) + de=${de:-Cinnamon} ;; - *"GNOME"*) - de="$(gnome-shell --version)" - de="${de/Shell }" + *GNOME*) + de=$(gnome-shell --version) + de=${de/Shell } ;; esac - (( "$KDE_SESSION_VERSION" >= "4" )) && de="${de/KDE/Plasma}" + ((KDE_SESSION_VERSION >= 4)) && de=${de/KDE/Plasma} - # Log that the function was run. de_run=1 } From 1f035379ff19b46195ee25b2b4274ba7519d59b3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 28 Oct 2019 09:48:08 +0200 Subject: [PATCH 13/19] neofetch: remove uneeded quotes --- neofetch | 143 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/neofetch b/neofetch index be6ddcbe..2a93a1e2 100755 --- a/neofetch +++ b/neofetch @@ -1585,111 +1585,112 @@ get_wm() { # If function was run, stop here. ((wm_run == 1)) && return - case "$uname" in - *"OpenBSD"*) ps_flags=(x -c) ;; - *) ps_flags=(-e) ;; + case $uname in + *OpenBSD*) ps_flags=(x -c) ;; + *) ps_flags=(-e) ;; esac - if [[ "$WAYLAND_DISPLAY" ]]; then - wm="$(ps "${ps_flags[@]}" | grep -m 1 -o -F \ - -e "arcan" \ - -e "asc" \ - -e "clayland" \ - -e "dwc" \ - -e "fireplace" \ - -e "greenfield" \ - -e "grefsen" \ - -e "lipstick" \ - -e "maynard" \ - -e "mazecompositor" \ - -e "motorcar" \ - -e "orbital" \ - -e "orbment" \ - -e "perceptia" \ - -e "rustland" \ - -e "sway" \ - -e "ulubis" \ - -e "velox" \ - -e "wavy" \ - -e "way-cooler" \ - -e "wayfire" \ - -e "wayhouse" \ - -e "westeros" \ - -e "westford" \ - -e "weston")" + if [[ $WAYLAND_DISPLAY ]]; then + wm=$(ps "${ps_flags[@]}" | grep -m 1 -o -F \ + -e arcan \ + -e asc \ + -e clayland \ + -e dwc \ + -e fireplace \ + -e greenfield \ + -e grefsen \ + -e lipstick \ + -e maynard \ + -e mazecompositor \ + -e motorcar \ + -e orbital \ + -e orbment \ + -e perceptia \ + -e rustland \ + -e sway \ + -e ulubis \ + -e velox \ + -e wavy \ + -e way-cooler \ + -e wayfire \ + -e wayhouse \ + -e westeros \ + -e westford \ + -e weston) - elif [[ "$DISPLAY" && "$os" != "Mac OS X" && "$os" != "FreeMiNT" ]]; then - if type -p xprop &>/dev/null; then - id="$(xprop -root -notype _NET_SUPPORTING_WM_CHECK)" - id="${id##* }" - wm="$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t)" - wm="${wm/*WM_NAME = }" - wm="${wm/\"}" - wm="${wm/\"*}" - fi + elif [[ $DISPLAY && $os != "Mac OS X" && $os != FreeMiNT ]]; then + type -p xprop &>/dev/null && { + id=$(xprop -root -notype _NET_SUPPORTING_WM_CHECK) + id=${id##* } + wm=$(xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t) + wm=${wm/*WM_NAME = } + wm=${wm/\"} + wm=${wm/\"*} + } # Rename window managers to their proper values. - [[ "$wm" =~ "WINDOWMAKER" ]] && wm="wmaker" - [[ "$wm" =~ "GNOME Shell" ]] && wm="Mutter" + [[ $wm == *WINDOWMAKER* ]] && wm=wmaker + [[ $wm == *"GNOME Shell"* ]] && wm=Mutter # Fallback for non-EWMH WMs. - [[ -z "$wm" ]] && \ - wm="$(ps "${ps_flags[@]}" | grep -m 1 -o \ + [[ $wm ]] || + wm=$(ps "${ps_flags[@]}" | grep -m 1 -o \ + -e "[s]owm" \ -e "[c]atwm" \ -e "[f]vwm" \ -e "[d]wm" \ -e "[2]bwm" \ -e "[m]onsterwm" \ - -e "[t]inywm")" + -e "[t]inywm") else - case "$os" in + case $os in "Mac OS X") - ps_line="$(ps -e | grep -o \ + ps_line=$(ps -e | grep -o \ -e "[S]pectacle" \ -e "[A]methyst" \ -e "[k]wm" \ -e "[c]hun[k]wm" \ -e "[y]abai" \ - -e "[R]ectangle")" + -e "[R]ectangle") - case "$ps_line" in - *"chunkwm"*) wm="chunkwm" ;; - *"kwm"*) wm="Kwm" ;; - *"yabai"*) wm="yabai" ;; - *"Amethyst"*) wm="Amethyst" ;; - *"Spectacle"*) wm="Spectacle" ;; - *"Rectangle"*) wm="Rectangle" ;; - *) wm="Quartz Compositor" ;; + case $ps_line in + *chunkwm*) wm=chunkwm ;; + *kwm*) wm=Kwm ;; + *yabai*) wm=yabai ;; + *Amethyst*) wm=Amethyst ;; + *Spectacle*) wm=Spectacle ;; + *Rectangle*) wm=Rectangle ;; + *) wm="Quartz Compositor" ;; esac ;; - "Windows") - wm="$(tasklist | grep -m 1 -o -F \ - -e "bugn" \ - -e "Windawesome" \ - -e "blackbox" \ - -e "emerge" \ - -e "litestep")" + Windows) + wm=$(tasklist | grep -m 1 -o -F \ + -e bugn \ + -e Windawesome \ + -e blackbox \ + -e emerge \ + -e litestep) - [[ "$wm" == "blackbox" ]] && wm="bbLean (Blackbox)" - wm="${wm:+$wm, }Explorer" + [[ $wm == blackbox ]] && wm="bbLean (Blackbox)" + wm=${wm:+$wm, }Explorer ;; - "FreeMiNT") + FreeMiNT) freemint_wm=(/proc/*) - case "${freemint_wm[*]}" in - *xaaes*) wm="XaAES" ;; - *myaes*) wm="MyAES" ;; - *naes*) wm="N.AES" ;; - geneva) wm="Geneva" ;; + + case ${freemint_wm[*]} in + *xaaes*) wm=XaAES ;; + *myaes*) wm=MyAES ;; + *naes*) wm=N.AES ;; + geneva) wm=Geneva ;; *) wm="Atari AES" ;; esac ;; esac fi - # Log that the function was run. wm_run=1 } From acdfbe2063d0a4f64c558b4dcd996b2f1fc95be4 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 28 Oct 2019 13:14:06 +0200 Subject: [PATCH 14/19] uptime: fix bug --- neofetch | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/neofetch b/neofetch index 2a93a1e2..a304cfad 100755 --- a/neofetch +++ b/neofetch @@ -1285,9 +1285,9 @@ get_uptime() { ((${m/ *} == 1)) && m=${m/s} # Hide empty fields. - ((${d/ *} == 0)) && unset days - ((${h/ *} == 0)) && unset hours - ((${m/ *} == 0)) && unset mins + ((${d/ *} == 0)) && unset d + ((${h/ *} == 0)) && unset h + ((${m/ *} == 0)) && unset m uptime=${d:+$d, }${h:+$h, }$m uptime=${uptime%', '} From 9f25f34fa1d939634430bb7a72018932cb4778a6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 28 Oct 2019 22:15:57 +0000 Subject: [PATCH 15/19] neofetch: remove unneeded quotes --- neofetch | 152 +++++++++++++++++++++++++++---------------------------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/neofetch b/neofetch index a304cfad..4984ffaf 100755 --- a/neofetch +++ b/neofetch @@ -1698,7 +1698,7 @@ get_wm_theme() { ((wm_run != 1)) && get_wm ((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")" ;; @@ -1820,7 +1820,7 @@ get_wm_theme() { [[ -z "$wm_theme" ]] && \ wm_theme="Light" - case "$wm_theme_color" in + case $wm_theme_color in "-1") wm_theme_color="Graphite" ;; "0") wm_theme_color="Red" ;; "1") wm_theme_color="Orange" ;; @@ -1858,12 +1858,12 @@ get_wm_theme() { } get_cpu() { - case "$os" in + case $os in "Linux" | "MINIX" | "Windows") # Get CPU name. cpu_file="/proc/cpuinfo" - case "$kernel_machine" in + case $kernel_machine in "frv" | "hppa" | "m68k" | "openrisc" | "or"* | "powerpc" | "ppc"* | "sparc"*) cpu="$(awk -F':' '/^cpu\t|^CPU/ {printf $2; exit}' "$cpu_file")" ;; @@ -1910,7 +1910,7 @@ get_cpu() { [[ -f "$temp_dir" ]] && deg="$(($(< "$temp_dir") * 100 / 10000))" # Get CPU cores. - case "$cpu_cores" in + case $cpu_cores in "logical" | "on") cores="$(grep -c "^processor" "$cpu_file")" ;; "physical") cores="$(awk '/^core id/&&!a[$0]++{++i} END {print i}' "$cpu_file")" ;; esac @@ -1920,14 +1920,14 @@ get_cpu() { cpu="$(sysctl -n machdep.cpu.brand_string)" # Get CPU cores. - case "$cpu_cores" in + case $cpu_cores in "logical" | "on") cores="$(sysctl -n hw.logicalcpu_max)" ;; "physical") cores="$(sysctl -n hw.physicalcpu_max)" ;; esac ;; "iPhone OS") - case "$kernel_machine" in + case $kernel_machine in "iPhone1,"[1-2] | "iPod1,1"): "Samsung S5L8900 (1) @ 412MHz" ;; "iPhone2,1"): "Samsung S5PC100 (1) @ 600MHz" ;; "iPhone3,"[1-3] | "iPod4,1"): "Apple A4 (1) @ 800MHz" ;; @@ -1976,7 +1976,7 @@ get_cpu() { cores="$(sysctl -n hw.ncpu)" # Get CPU temp. - case "$kernel_name" in + case $kernel_name in "FreeBSD"* | "DragonFly"* | "NetBSD"*) deg="$(sysctl -n dev.cpu.0.temperature)" deg="${deg/C}" @@ -2001,7 +2001,7 @@ get_cpu() { speed="$(psrinfo -v | awk '/operates at/ {print $6; exit}')" # Get CPU cores. - case "$cpu_cores" in + case $cpu_cores in "logical" | "on") cores="$(kstat -m cpu_info | grep -c -F "chip_id")" ;; "physical") cores="$(psrinfo -p)" ;; esac @@ -2029,7 +2029,7 @@ get_cpu() { speed="${speed/MHz}" # Get CPU cores. - case "$cpu_cores" in + case $cpu_cores in "logical" | "on") cores="$(lparstat -i | awk -F':' '/Online Virtual CPUs/ {printf $2}')" ;; @@ -2092,7 +2092,7 @@ get_cpu() { # Add CPU cores to the output. [[ "$cpu_cores" != "off" && "$cores" ]] && \ - case "$os" in + case $os in "Mac OS X") cpu="${cpu/@/(${cores}) @}" ;; *) cpu="$cpu ($cores)" ;; esac @@ -2122,7 +2122,7 @@ get_cpu() { } get_cpu_usage() { - case "$os" in + case $os in "Windows") cpu_usage="$(wmic cpu get loadpercentage)" cpu_usage="${cpu_usage/LoadPercentage}" @@ -2132,7 +2132,7 @@ get_cpu_usage() { *) # Get CPU cores if unset. if [[ "$cpu_cores" != "logical" ]]; then - case "$os" in + case $os in "Linux" | "MINIX") cores="$(grep -c "^processor" /proc/cpuinfo)" ;; "Mac OS X") cores="$(sysctl -n hw.logicalcpu_max)" ;; "BSD") cores="$(sysctl -n hw.ncpu)" ;; @@ -2154,7 +2154,7 @@ get_cpu_usage() { esac # Print the bar. - case "$cpu_display" in + case $cpu_display in "bar") cpu_usage="$(bar "$cpu_usage" 100)" ;; "infobar") cpu_usage="${cpu_usage}% $(bar "$cpu_usage" 100)" ;; "barinfo") cpu_usage="$(bar "$cpu_usage" 100)${info_color} ${cpu_usage}%" ;; @@ -2163,7 +2163,7 @@ get_cpu_usage() { } get_gpu() { - case "$os" in + case $os in "Linux") # Read GPUs into array. gpu_cmd="$(lspci -mm | awk -F '\"|\" \"|\\(' \ @@ -2186,7 +2186,7 @@ get_gpu() { [[ "$gpu_type" == "integrated" && ! "$gpu" == *Intel* ]] && \ { unset -v gpu; continue; } - case "$gpu" in + case $gpu in *"advanced"*) brand="${gpu/*AMD*ATI*/AMD ATI}" brand="${brand:-${gpu/*AMD*/AMD}}" @@ -2252,7 +2252,7 @@ get_gpu() { ;; "iPhone OS") - case "$kernel_machine" in + case $kernel_machine in "iPhone1,"[1-2]): "PowerVR MBX Lite 3D" ;; "iPhone5,"[1-4]): "PowerVR SGX543MP3" ;; "iPhone11,"[2468]): "G11P" ;; @@ -2303,7 +2303,7 @@ get_gpu() { ;; *) - case "$kernel_name" in + case $kernel_name in "FreeBSD"* | "DragonFly"*) gpu="$(pciconf -lv | grep -B 4 -F "VGA" | grep -F "device")" gpu="${gpu/*device*= }" @@ -2326,12 +2326,12 @@ get_gpu() { } get_memory() { - case "$os" in + case $os in "Linux" | "Windows") # MemUsed = Memtotal + Shmem - MemFree - Buffers - Cached - SReclaimable # Source: https://github.com/KittyKatt/screenFetch/issues/386#issuecomment-249312716 while IFS=":" read -r a b; do - case "$a" in + case $a in "MemTotal") ((mem_used+=${b/kB})); mem_total="${b/kB}" ;; "Shmem") ((mem_used+=${b/kB})) ;; "MemFree" | "Buffers" | "Cached" | "SReclaimable") @@ -2355,13 +2355,13 @@ get_memory() { "BSD" | "MINIX") # Mem total. - case "$kernel_name" in + case $kernel_name in "NetBSD"*) mem_total="$(($(sysctl -n hw.physmem64) / 1024 / 1024))" ;; *) mem_total="$(($(sysctl -n hw.physmem) / 1024 / 1024))" ;; esac # Mem free. - case "$kernel_name" in + case $kernel_name in "NetBSD"*) mem_free="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))" ;; @@ -2384,7 +2384,7 @@ get_memory() { esac # Mem used. - case "$kernel_name" in + case $kernel_name in "OpenBSD"*) mem_used="$(vmstat | awk 'END {printf $3}')" mem_used="${mem_used/M}" @@ -2396,7 +2396,7 @@ get_memory() { "Solaris" | "AIX") hw_pagesize="$(pagesize)" - case "$os" in + case $os in "Solaris") pages_total="$(kstat -p unix:0:system_pages:pagestotal | awk '{print $2}')" pages_free="$(kstat -p unix:0:system_pages:pagesfree | awk '{print $2}')" @@ -2444,7 +2444,7 @@ get_memory() { memory="${mem_used}${mem_label:-MiB} / ${mem_total}${mem_label:-MiB} ${mem_perc:+(${mem_perc}%)}" # Bars. - case "$memory_display" in + case $memory_display in "bar") memory="$(bar "${mem_used}" "${mem_total}")" ;; "infobar") memory="${memory} $(bar "${mem_used}" "${mem_total}")" ;; "barinfo") memory="$(bar "${mem_used}" "${mem_total}")${info_color} ${memory}" ;; @@ -2513,7 +2513,7 @@ get_song() { )" } - case "${player/*\/}" in + case ${player/*\/} in "mpd"*|"mopidy"*) song="$(mpc -f '%artist%\n%album%\n%title%' current "${mpc_args[@]}")" ;; "mocp"*) song="$(mocp -Q '%artist\n%album\n%song')" ;; "deadbeef"*) song="$(deadbeef --nowplaying-tf '%artist%\\n%album%\\n%title%')" ;; @@ -2561,7 +2561,7 @@ get_song() { ;; "spotify"*) - case "$os" in + case $os in "Linux") get_song_dbus "spotify" ;; "Mac OS X") @@ -2638,7 +2638,7 @@ get_song() { } get_resolution() { - case "$os" in + case $os in "Mac OS X") if type -p screenresolution >/dev/null; then resolution="$(screenresolution get 2>&1 | awk '/Display/ {printf $6 "Hz, "}')" @@ -2692,7 +2692,7 @@ get_resolution() { *) if type -p xrandr >/dev/null; then - case "$refresh_rate" in + case $refresh_rate in "on") resolution="$(xrandr --nograb --current |\ awk 'match($0,/[0-9]*\.[0-9]*\*/) { @@ -2732,7 +2732,7 @@ get_style() { ((de_run != 1)) && get_de # Check for DE Theme. - case "$de" in + case $de in "KDE"* | "Plasma"*) kde_config_dir @@ -2895,7 +2895,7 @@ get_term() { # Workaround for macOS systems that # don't support the block below. - case "$TERM_PROGRAM" in + case $TERM_PROGRAM in "iTerm.app") term="iTerm2" ;; "Terminal.app") term="Apple Terminal" ;; "Hyper") term="HyperTerm" ;; @@ -2912,7 +2912,7 @@ get_term() { [[ -z "$parent" ]] && break name="$(get_process_name "$parent")" - case "${name// }" in + case ${name// } in "${SHELL/*\/}"|*"sh"|"screen"|"su"*) ;; "login"*|*"Login"*|"init"|"(init)") @@ -2950,7 +2950,7 @@ get_term() { get_term_font() { ((term_run != 1)) && get_term - case "$term" in + case $term in "alacritty"*) shopt -s nullglob confs=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?) @@ -3204,7 +3204,7 @@ END # Xresources has two different font formats, this checks which # one is in use and formats it accordingly. - case "$term_font" in + case $term_font in *"xft:"*) term_font="${term_font/xft:}" term_font="${term_font/:*}" @@ -3237,7 +3237,7 @@ get_disk() { df_version="$(df --version 2>&1)" - case "$df_version" in + case $df_version in *"IMitv"*) df_flags=(-P -g) ;; # AIX *"befhikm"*) df_flags=(-P -k) ;; # IRIX *"hiklnP"*) df_flags=(-h) ;; # OpenBSD @@ -3266,7 +3266,7 @@ get_disk() { IFS=" " read -ra disk_info <<< "$disk" disk_perc="${disk_info[4]/\%}" - case "$df_version" in + case $df_version in *"befhikm"*) disk="$((disk_info[2]/1024/1024))G / $((disk_info[1]/1024/1024))G (${disk_perc}%)" ;; @@ -3277,7 +3277,7 @@ get_disk() { esac # Subtitle. - case "$disk_subtitle" in + case $disk_subtitle in "name") disk_sub="${disk_info[0]}" ;; @@ -3293,7 +3293,7 @@ get_disk() { esac # Bar. - case "$disk_display" in + case $disk_display in "bar") disk="$(bar "$disk_perc" "100")" ;; "infobar") disk+=" $(bar "$disk_perc" "100")" ;; "barinfo") disk="$(bar "$disk_perc" "100")${info_color} $disk" ;; @@ -3310,7 +3310,7 @@ get_disk() { } get_battery() { - case "$os" in + case $os in "Linux") # We use 'prin' here so that we can do multi battery support # with a single battery per line. @@ -3321,7 +3321,7 @@ get_battery() { if [[ "$capacity" ]]; then battery="${capacity}% [${status}]" - case "$battery_display" in + case $battery_display in "bar") battery="$(bar "$capacity" 100)" ;; "infobar") battery+=" $(bar "$capacity" 100)" ;; "barinfo") battery="$(bar "$capacity" 100)${info_color} ${battery}" ;; @@ -3335,7 +3335,7 @@ get_battery() { ;; "BSD") - case "$kernel_name" in + case $kernel_name in "FreeBSD"* | "DragonFly"*) battery="$(acpiconf -i 0 | awk -F ':\t' '/Remaining capacity/ {print $2}')" battery_state="$(acpiconf -i 0 | awk -F ':\t\t\t' '/State/ {print $2}')" @@ -3387,7 +3387,7 @@ get_battery() { [[ "$battery_state" ]] && battery+=" Charging" - case "$battery_display" in + case $battery_display in "bar") battery="$(bar "${battery/\%*}" 100)" ;; "infobar") battery="${battery} $(bar "${battery/\%*}" 100)" ;; "barinfo") battery="$(bar "${battery/\%*}" 100)${info_color} ${battery}" ;; @@ -3395,7 +3395,7 @@ get_battery() { } get_local_ip() { - case "$os" in + case $os in "Linux" | "BSD" | "Solaris" | "AIX" | "IRIX") local_ip="$(ip route get 1 | awk -F'src' '{print $2; exit}')" local_ip="${local_ip/uid*}" @@ -3453,7 +3453,7 @@ get_locale() { } get_gpu_driver() { - case "$os" in + case $os in "Linux") gpu_driver="$(lspci -nnk | awk -F ': ' \ '/Display|3D|VGA/{nr[NR+2]}; NR in nr {printf $2 ", "}')" @@ -3485,7 +3485,7 @@ get_cols() { # Generate the string. for ((block_range[0]; block_range[0]<=block_range[1]; block_range[0]++)); do - case "${block_range[0]}" in + case ${block_range[0]} in [0-7]) printf -v blocks '%b\e[3%bm\e[4%bm%b' \ "$blocks" "${block_range[0]}" "${block_range[0]}" "$block_width" @@ -3531,7 +3531,7 @@ image_backend() { [[ "$image_backend" != "off" ]] && ! type -p convert &>/dev/null && \ { image_backend="ascii"; err "Image: Imagemagick not found, falling back to ascii mode."; } - case "${image_backend:-off}" in + case ${image_backend:-off} in "ascii") print_ascii ;; "off") image_backend="off" ;; @@ -3606,7 +3606,7 @@ print_ascii() { } get_image_source() { - case "$image_source" in + case $image_source in "auto" | "wall" | "wallpaper") get_wallpaper ;; @@ -3631,7 +3631,7 @@ get_image_source() { } get_wallpaper() { - case "$os" in + case $os in "Mac OS X") image="$(osascript </dev/null && [[ -f "${HOME}/.cache/wal/wal" ]] && \ { image="$(< "${HOME}/.cache/wal/wal")"; return; } - case "$de" in + case $de in "MATE"*) image="$(gsettings get org.mate.background picture-filename)" ;; @@ -3739,7 +3739,7 @@ get_window_size() { printf '%b' '\e}qs\000' elif [[ -z $VTE_VERSION ]]; then - case "${TMUX:-null}" in + case ${TMUX:-null} in "null") printf '%b' '\e[14t' ;; *) printf '%b' '\ePtmux;\e\e[14t\e\\ ' ;; esac @@ -3749,7 +3749,7 @@ get_window_size() { # user input so we have to use read to store the out # -put as a variable. # The 1 second timeout is required for older bash - case "${BASH_VERSINFO[0]}" in + case ${BASH_VERSINFO[0]} in 4|5) IFS=';t' read -d t -t 0.05 -sra term_size ;; *) IFS=';t' read -d t -t 1 -sra term_size ;; esac @@ -3819,7 +3819,7 @@ get_image_size() { # This functions determines the size to make the thumbnail image. get_term_size - case "$image_size" in + case $image_size in "auto") image_size="$((columns * font_width / 2))" term_height="$((term_height - term_height / 4))" @@ -3864,7 +3864,7 @@ make_thumbnail() { image_name="${crop_mode}-${crop_offset}-${width}-${height}-${image//\/}" # Handle file extensions. - case "${image##*.}" in + case ${image##*.} in "eps"|"pdf"|"svg"|"gif"|"png") image_name+=".png" ;; *) image_name+=".jpg" ;; @@ -3880,7 +3880,7 @@ make_thumbnail() { ((og_height > og_width)) && size="$og_width" || size="$og_height" } - case "$crop_mode" in + case $crop_mode in "fit") c="$(convert "$image" \ -colorspace srgb \ @@ -3929,7 +3929,7 @@ make_thumbnail() { } display_image() { - case "$image_backend" in + case $image_backend in "caca") img2txt \ -W "$((width / font_width))" \ @@ -4096,12 +4096,12 @@ get_underline() { } get_bold() { - case "$ascii_bold" in + case $ascii_bold in "on") ascii_bold='\e[1m' ;; "off") ascii_bold="" ;; esac - case "$bold" in + case $bold in "on") bold='\e[1m' ;; "off") bold="" ;; esac @@ -4177,15 +4177,15 @@ set_text_colors() { bar_color_elapsed="$(color "$bar_color_elapsed")" fi - case "$bar_color_total $1" in - "distro "[736]) bar_color_total="$(color "$1")" ;; - "distro "[0-9]) bar_color_total="$(color "$2")" ;; - *) bar_color_total="$(color "$bar_color_total")" ;; + case ${bar_color_total}${1} in + distro[736]) bar_color_total=$(color "$1") ;; + distro[0-9]) bar_color_total=$(color "$2") ;; + *) bar_color_total=$(color "$bar_color_total") ;; esac } color() { - case "$1" in + case $1 in [0-6]) printf '%b\e[3%sm' "$reset" "$1" ;; 7 | "fg") printf '\e[37m%b' "$reset" ;; *) printf '\e[38;5;%bm' "$1" ;; @@ -4285,7 +4285,7 @@ cache() { } get_cache_dir() { - case "$os" in + case $os in "Mac OS X") cache_dir="/Library/Caches" ;; *) cache_dir="/tmp" ;; esac @@ -4320,7 +4320,7 @@ term_padding() { # Get terminal padding to properly align cursor. [[ -z "$term" ]] && get_term - case "$term" in + case $term in urxvt*|"rxvt-unicode") [[ -z "$xrdb" ]] && xrdb="$(xrdb -query)" @@ -4373,7 +4373,7 @@ cache_uname() { get_ppid() { # Get parent process ID of PID. - case "$os" in + case $os in "Windows") ppid="$(ps -p "${1:-$PPID}" | awk '{printf $2}')" ppid="${ppid/PPID}" @@ -4394,7 +4394,7 @@ get_ppid() { get_process_name() { # Get PID name. - case "$os" in + case $os in "Windows") name="$(ps -p "${1:-$PPID}" | awk '{printf $8}')" name="${name/COMMAND}" @@ -4654,7 +4654,7 @@ get_args() { [[ "$*" != *--config* && "$*" != *--no_config* ]] && get_user_config while [[ "$1" ]]; do - case "$1" in + case $1 in # Info "--package_managers") package_managers="$2" ;; "--os_arch") os_arch="$2" ;; @@ -4689,7 +4689,7 @@ get_args() { "--disk_show") unset disk_show for arg in "$@"; do - case "$arg" in + case $arg in "--disk_show") ;; "-"*) break ;; *) disk_show+=("$arg") ;; @@ -4699,7 +4699,7 @@ get_args() { "--disable") for func in "$@"; do - case "$func" in + case $func in "--disable") continue ;; "-"*) break ;; *) @@ -4714,7 +4714,7 @@ get_args() { "--colors") unset colors for arg in "$2" "$3" "$4" "$5" "$6" "$7"; do - case "$arg" in + case $arg in "-"*) break ;; *) colors+=("$arg") ;; esac @@ -4758,7 +4758,7 @@ get_args() { "--ascii" | "--caca" | "--chafa" | "--jp2a" | "--iterm2" | "--off" | "--pixterm" |\ "--sixel" | "--termpix" | "--tycat" | "--w3m" | "--kitty") image_backend="${1/--}" - case "$2" in + case $2 in "-"* | "") ;; *) image_source="$2" ;; esac @@ -4783,7 +4783,7 @@ get_args() { "--ascii_colors") unset ascii_colors for arg in "$2" "$3" "$4" "$5" "$6" "$7"; do - case "$arg" in + case $arg in "-"*) break ;; *) ascii_colors+=("$arg") esac @@ -4804,7 +4804,7 @@ get_args() { # Other "--config") - case "$2" in + case $2 in "none" | "off" | "") ;; *) config_file="$(get_full_path "$2")" @@ -4922,7 +4922,7 @@ get_distro_ascii() { # This function gets the distro ascii art and colors. # # $ascii_distro is the same as $distro. - case "$(trim "$ascii_distro")" in + case $(trim "$ascii_distro") in "AIX"*) set_colors 2 7 read -rd '' ascii_data <<'EOF' @@ -9400,7 +9400,7 @@ EOF ;; *) - case "$kernel_name" in + case $kernel_name in *"BSD") set_colors 1 7 4 3 6 read -rd '' ascii_data <<'EOF' From 13f2d3a1732e5c33b3238462a2f68972c5b0f11e Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 30 Oct 2019 12:11:10 +0000 Subject: [PATCH 16/19] neofetch: Added initial support for HardenedBSD. Closes #1050 --- neofetch | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 4984ffaf..ef83acdc 100755 --- a/neofetch +++ b/neofetch @@ -957,9 +957,10 @@ get_distro() { distro=${distro/DragonFly/DragonFlyBSD} # Workarounds for some BSD based distros. - [[ -f /etc/pcbsd-lang ]] && distro=PCBSD - [[ -f /etc/trueos-lang ]] && distro=TrueOS - [[ -f /etc/pacbsd-release ]] && distro=PacBSD + [[ -f /etc/pcbsd-lang ]] && distro=PCBSD + [[ -f /etc/trueos-lang ]] && distro=TrueOS + [[ -f /etc/pacbsd-release ]] && distro=PacBSD + [[ -f /etc/hbsd-update.conf ]] && distro=HardenedBSD fi fi @@ -6419,7 +6420,7 @@ ${c1}/\\,-'''''-,/\\ EOF ;; - "FreeBSD"*) + "FreeBSD"*|HardenedBSD*) set_colors 1 7 3 read -rd '' ascii_data <<'EOF' ${c2}``` ${c1}` From 96f3aa948dc0eea20a317fe447f154b6f9bc3ec3 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 30 Oct 2019 12:13:42 +0000 Subject: [PATCH 17/19] ascii: fix Manjaro gap. Closes #1175 --- neofetch | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index ef83acdc..5b3d7840 100755 --- a/neofetch +++ b/neofetch @@ -3586,7 +3586,8 @@ print_ascii() { # Calculate size of ascii file in line length / line count. while IFS=$'\n' read -r line; do - line="${line//\\\\/\\}" + line=${line//\\\\/\\} + line=${line//█/ } ((++lines,${#line}>ascii_len)) && ascii_len="${#line}" done <<< "${ascii_data//\$\{??\}}" From 1c9db4af1ac876fdc28fc974dbc668ae8ccf60bd Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 30 Oct 2019 12:20:16 +0000 Subject: [PATCH 18/19] neofetch: fix #1279 --- neofetch | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/neofetch b/neofetch index 5b3d7840..b20f90b4 100755 --- a/neofetch +++ b/neofetch @@ -4323,15 +4323,14 @@ term_padding() { [[ -z "$term" ]] && get_term case $term in - urxvt*|"rxvt-unicode") - [[ -z "$xrdb" ]] && - xrdb="$(xrdb -query)" + urxvt*|rxvt-unicode) + [[ $xrdb ]] || xrdb=$(xrdb -query) - [[ $xrdb != *".internalBorder:"* ]] && + [[ $xrdb != *internalBorder:* ]] && return - padding="${xrdb/*.internalBorder:}" - padding="${padding/$'\n'*}" + padding=${xrdb/*internalBorder:} + padding=${padding/$'\n'*} [[ $padding =~ ^[0-9]+$ ]] || padding= From 9bb236eb4b8d1cf0353b8dc454b1e7030a97e006 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Wed, 30 Oct 2019 12:25:33 +0000 Subject: [PATCH 19/19] neofetch: Fix urxvt font, closes #1253 --- neofetch | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/neofetch b/neofetch index b20f90b4..742349b4 100755 --- a/neofetch +++ b/neofetch @@ -3186,32 +3186,32 @@ END "$termite_config")" ;; - "urxvt" | "urxvtd" | "rxvt-unicode" | "xterm") - xrdb="$(xrdb -query)" - term_font="$(grep -im 1 -e "^${term/d}"'\**\.*font' -e '^\*font' <<< "$xrdb")" - term_font="${term_font/*"*font:"}" - term_font="${term_font/*".font:"}" - term_font="${term_font/*"*.font:"}" - term_font="$(trim "$term_font")" + urxvt|urxvtd|rxvt-unicode|xterm) + xrdb=$(xrdb -query) + term_font=$(grep -im 1 -e "^${term/d}"'\**\.*font:' -e '^\*font:' <<< "$xrdb") + term_font=${term_font/*"*font:"} + term_font=${term_font/*".font:"} + term_font=${term_font/*"*.font:"} + term_font=$(trim "$term_font") - [[ -z "$term_font" && "$term" == "xterm" ]] && \ - term_font="$(grep '^XTerm.vt100.faceName' <<< "$xrdb")" + [[ -z $term_font && $term == xterm ]] && \ + term_font=$(grep '^XTerm.vt100.faceName' <<< "$xrdb") - term_font="$(trim "${term_font/*"faceName:"}")" + term_font=$(trim "${term_font/*"faceName:"}") # xft: isn't required at the beginning so we prepend it if it's missing - [[ "${term_font:0:1}" != "-" && "${term_font:0:4}" != "xft:" ]] && \ - term_font="xft:$term_font" + [[ ${term_font:0:1} != '-' && ${term_font:0:4} != xft: ]] && \ + term_font=xft:$term_font # Xresources has two different font formats, this checks which # one is in use and formats it accordingly. case $term_font in - *"xft:"*) - term_font="${term_font/xft:}" - term_font="${term_font/:*}" + *xft:*) + term_font=${term_font/xft:} + term_font=${term_font/:*} ;; - "-"*) + -*) IFS=- read -r _ _ term_font _ <<< "$term_font" ;; esac