neofetch: remove uneeded quotes

This commit is contained in:
Dylan Araps 2019-10-28 09:40:04 +02:00
parent 85f7b7852a
commit 93600efc6a
No known key found for this signature in database
GPG Key ID: 46D62DD9F1DE636E
1 changed files with 143 additions and 139 deletions

266
neofetch
View File

@ -1315,13 +1315,13 @@ get_packages() {
# dir: Count files or dirs in a glob. # dir: Count files or dirs in a glob.
# pac: If packages > 0, log package manager name. # pac: If packages > 0, log package manager name.
# tot: Count lines in command output. # tot: Count lines in command output.
has() { type -p "$1" >/dev/null && manager="$_"; } has() { type -p "$1" >/dev/null && manager=$_; }
dir() { ((packages+=$#)); pac "$#"; } dir() { ((packages+=$#)); pac "$#"; }
pac() { (($1 > 0)) && { managers+=("$1 (${manager})"); manager_string+="${manager}, "; }; } pac() { (($1 > 0)) && { managers+=("$1 (${manager})"); manager_string+="${manager}, "; }; }
tot() { IFS=$'\n' read -d "" -ra pkgs <<< "$("$@")";((packages+=${#pkgs[@]}));pac "${#pkgs[@]}";} tot() { IFS=$'\n' read -d "" -ra pkgs <<< "$("$@")";((packages+=${#pkgs[@]}));pac "${#pkgs[@]}";}
# Redefine tot() for Bedrock Linux. # Redefine tot() for Bedrock Linux.
[[ -f "/bedrock/etc/bedrock-release" && "$PATH" == */bedrock/cross/* ]] && { [[ -f /bedrock/etc/bedrock-release && $PATH == */bedrock/cross/* ]] && {
tot() { tot() {
IFS=$'\n' read -d "" -ra pkgs <<< "$(for s in $(brl list); do strat -r "$s" "$@"; done)" IFS=$'\n' read -d "" -ra pkgs <<< "$(for s in $(brl list); do strat -r "$s" "$@"; done)"
((packages+="${#pkgs[@]}")) ((packages+="${#pkgs[@]}"))
@ -1330,25 +1330,25 @@ get_packages() {
br_prefix="/bedrock/strata/*" br_prefix="/bedrock/strata/*"
} }
case "$os" in case $os in
"Linux" | "BSD" | "iPhone OS" | "Solaris") Linux|BSD|"iPhone OS"|Solaris)
# Package Manager Programs. # Package Manager Programs.
has "kiss" && tot kiss l has kiss && tot kiss l
has "pacman-key" && tot pacman -Qq --color never has pacman-key && tot pacman -Qq --color never
has "dpkg" && tot dpkg-query -f '.\n' -W has dpkg && tot dpkg-query -f '.\n' -W
has "rpm" && tot rpm -qa has rpm && tot rpm -qa
has "xbps-query" && tot xbps-query -l has xbps-query && tot xbps-query -l
has "apk" && tot apk info has apk && tot apk info
has "opkg" && tot opkg list-installed has opkg && tot opkg list-installed
has "pacman-g2" && tot pacman-g2 -Q has pacman-g2 && tot pacman-g2 -Q
has "lvu" && tot lvu installed has lvu && tot lvu installed
has "tce-status" && tot tce-status -i has tce-status && tot tce-status -i
has "pkg_info" && tot pkg_info has pkg_info && tot pkg_info
has "tazpkg" && tot tazpkg list && ((packages-=6)) has tazpkg && tot tazpkg list && ((packages-=6))
has "sorcery" && tot gaze installed has sorcery && tot gaze installed
has "alps" && tot alps showinstalled has alps && tot alps showinstalled
has "butch" && tot butch list has butch && tot butch list
has "bonsai" && tot bonsai list has bonsai && tot bonsai list
# Counting files/dirs. # Counting files/dirs.
# Variables need to be unquoted here. Only Bedrock Linux is affected. # Variables need to be unquoted here. Only Bedrock Linux is affected.
@ -1356,92 +1356,93 @@ get_packages() {
# shellcheck disable=SC2086 # shellcheck disable=SC2086
{ {
shopt -s nullglob shopt -s nullglob
has "brew" && dir "$(brew --cellar)"/* has brew && dir "$(brew --cellar)"/*
has "emerge" && dir ${br_prefix}/var/db/pkg/*/*/ has emerge && dir ${br_prefix}/var/db/pkg/*/*/
has "Compile" && dir ${br_prefix}/Programs/*/ has Compile && dir ${br_prefix}/Programs/*/
has "eopkg" && dir ${br_prefix}/var/lib/eopkg/package/* has eopkg && dir ${br_prefix}/var/lib/eopkg/package/*
has "crew" && dir ${br_prefix}/usr/local/etc/crew/meta/*.filelist has crew && dir ${br_prefix}/usr/local/etc/crew/meta/*.filelist
has "pkgtool" && dir ${br_prefix}/var/log/packages/* has pkgtool && dir ${br_prefix}/var/log/packages/*
has "kagami" && dir ${br_prefix}/var/lib/kagami/pkgs/* has kagami && dir ${br_prefix}/var/lib/kagami/pkgs/*
has "cave" && dir ${br_prefix}/var/db/paludis/repositories/cross-installed/*/data/*/ \ has cave && dir ${br_prefix}/var/db/paludis/repositories/cross-installed/*/data/*/ \
${br_prefix}/var/db/paludis/repositories/installed/data/*/ ${br_prefix}/var/db/paludis/repositories/installed/data/*/
shopt -u nullglob shopt -u nullglob
} }
# Other (Needs complex command) # 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 has guix && {
manager="guix-system" && tot guix package -p "/run/current-system/profile" -I manager=guix-system && tot guix package -p "/run/current-system/profile" -I
manager="guix-user" && tot guix package -I manager=guix-user && tot guix package -I
fi }
if has "nix-store"; then has nix-store && {
manager="nix-system" && tot nix-store -q --requisites "/run/current-system/sw" manager=nix-system && tot nix-store -q --requisites "/run/current-system/sw"
manager="nix-user" && tot nix-store -q --requisites "$HOME/.nix-profile" manager=nix-user && tot nix-store -q --requisites "$HOME/.nix-profile"
fi }
# pkginfo is also the name of a python package manager which is painfully slow. # pkginfo is also the name of a python package manager which is painfully slow.
# TODO: Fix this somehow. # TODO: Fix this somehow.
has pkginfo && tot pkginfo -i has pkginfo && tot pkginfo -i
case "$kernel_name" in case $kernel_name in
"FreeBSD"|"DragonFly") has "pkg" && tot pkg info ;; FreeBSD|DragonFly) has pkg && tot pkg info ;;
*) *)
has "pkg" && dir /var/db/pkg/* has pkg && dir /var/db/pkg/*
((packages == 0)) && \ ((packages == 0)) && \
has "pkg" && tot pkg list has pkg && tot pkg list
;; ;;
esac esac
# List these last as they accompany regular package managers. # List these last as they accompany regular package managers.
has "flatpak" && tot flatpak list has flatpak && tot flatpak list
has "spm" && tot spm list -i has spm && tot spm list -i
has "puyo" && dir ~/.puyo/installed has puyo && dir ~/.puyo/installed
# Snap hangs if the command is run without the daemon running. # Snap hangs if the command is run without the daemon running.
# Only run snap if the daemon is also 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") "Mac OS X"|MINIX)
has "port" && tot port installed && ((packages-=1)) has port && tot port installed && ((packages-=1))
has "brew" && dir /usr/local/Cellar/* has brew && dir /usr/local/Cellar/*
has "pkgin" && tot pkgin list has pkgin && tot pkgin list
if has "nix-store"; then has nix-store && {
manager="nix-system" && tot nix-store -q --requisites "/run/current-system/sw" manager=nix-system && tot nix-store -q --requisites "/run/current-system/sw"
manager="nix-user" && tot nix-store -q --requisites "$HOME/.nix-profile" manager=nix-user && tot nix-store -q --requisites "$HOME/.nix-profile"
fi }
;; ;;
"AIX"| "FreeMiNT") AIX|FreeMiNT)
has "lslpp" && ((packages+="$(lslpp -J -l -q | grep -cv '^#')")) has lslpp && ((packages+=$(lslpp -J -l -q | grep -cv '^#')))
has "rpm" && tot rpm -qa has rpm && tot rpm -qa
;; ;;
"Windows") Windows)
case "$kernel_name" in case $kernel_name in
"CYGWIN"*) has "cygcheck" && tot cygcheck -cd ;; CYGWIN*) has cygcheck && tot cygcheck -cd ;;
"MSYS"*) has "pacman" && tot pacman -Qq --color never ;; MSYS*) has pacman && tot pacman -Qq --color never ;;
esac esac
# Scoop environment throws errors if `tot scoop list` is used # 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. # Count chocolatey packages.
[[ -d "/cygdrive/c/ProgramData/chocolatey/lib" ]] && \ [[ -d /cygdrive/c/ProgramData/chocolatey/lib ]] && \
dir /cygdrive/c/ProgramData/chocolatey/lib/* dir /cygdrive/c/ProgramData/chocolatey/lib/*
;; ;;
"Haiku") Haiku)
has "pkgman" && dir /boot/system/package-links/* has pkgman && dir /boot/system/package-links/*
packages=${packages/pkgman/depot} packages=${packages/pkgman/depot}
;; ;;
"IRIX") IRIX)
manager="swpkg" manager=swpkg
tot versions -b && ((packages-=3)) tot versions -b && ((packages-=3))
;; ;;
esac esac
@ -1449,131 +1450,134 @@ get_packages() {
if ((packages == 0)); then if ((packages == 0)); then
unset packages unset packages
elif [[ "$package_managers" == "on" ]]; then elif [[ $package_managers == on ]]; then
printf -v packages '%s, ' "${managers[@]}" printf -v packages '%s, ' "${managers[@]}"
packages="${packages%,*}" packages=${packages%,*}
elif [[ "$package_managers" == "tiny" ]]; then elif [[ $package_managers == tiny ]]; then
packages+=" (${manager_string%,*})" packages+=" (${manager_string%,*})"
fi fi
packages="${packages/pacman-key/pacman}" packages=${packages/pacman-key/pacman}
} }
get_shell() { get_shell() {
case "$shell_path" in case $shell_path in
"on") shell="$SHELL " ;; on) shell="$SHELL " ;;
"off") shell="${SHELL##*/} " ;; off) shell="${SHELL##*/} " ;;
esac esac
if [[ "$shell_version" == "on" ]]; then [[ $shell_version != on ]] && return
case "${shell_name:=${SHELL##*/}}" in
"bash") shell+="${BASH_VERSION/-*}" ;;
"sh" | "ash" | "dash") ;;
*"ksh") case ${shell_name:=${SHELL##*/}} in
shell+="$("$SHELL" -c "printf %s \"\$KSH_VERSION\"")" bash) shell+=${BASH_VERSION/-*} ;;
shell="${shell/ * KSH}"
shell="${shell/version}" sh|ash|dash) ;;
*ksh)
shell+=$("$SHELL" -c "printf %s \"\$KSH_VERSION\"")
shell=${shell/ * KSH}
shell=${shell/version}
;; ;;
"tcsh") tcsh)
shell+="$("$SHELL" -c "printf %s \$tcsh")" shell+=$("$SHELL" -c "printf %s \$tcsh")
;; ;;
*) *)
shell+="$("$SHELL" --version 2>&1)" shell+=$("$SHELL" --version 2>&1)
shell="${shell/ "${shell_name}"}" shell=${shell/ $shell_name}
;; ;;
esac esac
# Remove unwanted info. # Remove unwanted info.
shell="${shell/, version}" shell=${shell/, version}
shell="${shell/xonsh\//xonsh }" shell=${shell/xonsh\//xonsh }
shell="${shell/options*}" shell=${shell/options*}
shell="${shell/\(*\)}" shell=${shell/\(*\)}
fi
} }
get_de() { get_de() {
# If function was run, stop here. # If function was run, stop here.
((de_run == 1)) && return ((de_run == 1)) && return
case "$os" in case $os in
"Mac OS X") de="Aqua" ;; "Mac OS X") de=Aqua ;;
"Windows")
case "$distro" in Windows)
case $distro in
"Windows 8"*|"Windows 10"*) de="Modern UI/Metro" ;; "Windows 8"*|"Windows 10"*) de="Modern UI/Metro" ;;
*) de="Aero" ;; *) de=Aero
esac esac
;; ;;
"FreeMiNT") FreeMiNT)
freemint_wm=(/proc/*) freemint_wm=(/proc/*)
case "${freemint_wm[*]}" in
*thing*) de="Thing" ;; case ${freemint_wm[*]} in
*jinnee*) de="Jinnee" ;; *thing*) de=Thing ;;
*tera*) de="Teradesk" ;; *jinnee*) de=Jinnee ;;
*neod*) de="NeoDesk" ;; *tera*) de=Teradesk ;;
*zdesk*) de="zDesk" ;; *neod*) de=NeoDesk ;;
*mdesk*) de="mDesk" ;; *zdesk*) de=zDesk ;;
*mdesk*) de=mDesk ;;
esac esac
;; ;;
*) *)
((wm_run != 1)) && get_wm ((wm_run != 1)) && get_wm
if [[ "$XDG_CURRENT_DESKTOP" ]]; then if [[ $XDG_CURRENT_DESKTOP ]]; then
de="${XDG_CURRENT_DESKTOP/X\-}" de=${XDG_CURRENT_DESKTOP/X\-}
de="${de/Budgie:GNOME/Budgie}" de=${de/Budgie:GNOME/Budgie}
de="${de/:Unity7:ubuntu}" de=${de/:Unity7:ubuntu}
elif [[ "$DESKTOP_SESSION" ]]; then elif [[ $DESKTOP_SESSION ]]; then
de="${DESKTOP_SESSION##*/}" de=${DESKTOP_SESSION##*/}
elif [[ "$GNOME_DESKTOP_SESSION_ID" ]]; then elif [[ $GNOME_DESKTOP_SESSION_ID ]]; then
de="GNOME" de=GNOME
elif [[ "$MATE_DESKTOP_SESSION_ID" ]]; then elif [[ $MATE_DESKTOP_SESSION_ID ]]; then
de="MATE" de=MATE
elif [[ "$TDE_FULL_SESSION" ]]; then elif [[ $TDE_FULL_SESSION ]]; then
de="Trinity" de=Trinity
fi fi
# When a window manager is started from a display manager # When a window manager is started from a display manager
# the desktop variables are sometimes also set to the # the desktop variables are sometimes also set to the
# window manager name. This checks to see if WM == DE # window manager name. This checks to see if WM == DE
# and dicards the DE value. # and dicards the DE value.
[[ "$de" == "$wm" ]] && { unset -v de; return; } [[ $de == "$wm" ]] && { unset -v de; return; }
;; ;;
esac esac
# Fallback to using xprop. # Fallback to using xprop.
[[ "$DISPLAY" && -z "$de" ]] && type -p xprop &>/dev/null && \ [[ $DISPLAY && -z $de ]] && type -p xprop &>/dev/null && \
de="$(xprop -root | awk '/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5/')" de=$(xprop -root | awk '/KDE_SESSION_VERSION|^_MUFFIN|xfce4|xfce5/')
# Format strings. # Format strings.
case "$de" in case $de in
"KDE_SESSION_VERSION"*) de="KDE${de/* = }" ;; KDE_SESSION_VERSION*) de=KDE${de/* = } ;;
*"xfce4"*) de="Xfce4" ;; *xfce4*) de=Xfce4 ;;
*"xfce5"*) de="Xfce5" ;; *xfce5*) de=Xfce5 ;;
*"xfce"*) de="Xfce" ;; *xfce*) de=Xfce ;;
*"mate"*) de="MATE" ;; *mate*) de=MATE ;;
*"MUFFIN"* | "Cinnamon") *MUFFIN*|Cinnamon)
de="$(cinnamon --version)"; de="${de:-Cinnamon}" de=$(cinnamon --version)
de=${de:-Cinnamon}
;; ;;
*"GNOME"*) *GNOME*)
de="$(gnome-shell --version)" de=$(gnome-shell --version)
de="${de/Shell }" de=${de/Shell }
;; ;;
esac 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 de_run=1
} }