Expanded distro_shorthand to support non-LSB solutions

This commit is contained in:
Muhammad Herdiansyah 2016-08-31 21:43:53 +07:00
parent 14ed583d68
commit e2af2772fe
4 changed files with 36 additions and 17 deletions

View File

@ -369,8 +369,8 @@ alias neofetch2="neofetch \
--cpu_shorthand type Shorten the output of CPU --cpu_shorthand type Shorten the output of CPU
Possible values: name, speed, tiny, on, off Possible values: name, speed, tiny, on, off
--cpu_cores on/off Whether or not to display the number of CPU cores --cpu_cores on/off Whether or not to display the number of CPU cores
--distro_shorthand on/off Shorten the output of distro --distro_shorthand on/off Shorten the output of distro (tiny, on, off)
NOTE: This is only possible on Linux with lsb_release NOTE: This is only possible on Linux
--kernel_shorthand on/off Shorten the output of kernel --kernel_shorthand on/off Shorten the output of kernel
--uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) --uptime_shorthand on/off Shorten the output of uptime (tiny, on, off)
--refresh_rate on/off Whether to display the refresh rate of each monitor --refresh_rate on/off Whether to display the refresh rate of each monitor

View File

@ -61,8 +61,8 @@ kernel_shorthand="on"
# Distro # Distro
# Shorten the output of distro # Shorten the output of distro (tiny, on, off)
# NOTE: This is only possible on Linux with lsb_release # NOTE: This is only possible on Linux
distro_shorthand="off" distro_shorthand="off"
# Mac OS X hide/show build version # Mac OS X hide/show build version

View File

@ -121,8 +121,8 @@ getdistro() {
if type -p lsb_release >/dev/null 2>&1; then if type -p lsb_release >/dev/null 2>&1; then
case "$distro_shorthand" in case "$distro_shorthand" in
"on") distro="$(lsb_release -sir 2>/dev/null)" ;; "on") distro="$(lsb_release -sir 2>/dev/null)" ;;
"off") distro="$(lsb_release -sd 2>/dev/null)" "tiny") distro="$(lsb_release -si 2>/dev/null)" ;;
distro="${distro//\"}" ;; *) distro="$(lsb_release -sd 2>/dev/null)" ;;
esac esac
elif type -p guix >/dev/null 2>&1; then elif type -p guix >/dev/null 2>&1; then
@ -130,16 +130,35 @@ getdistro() {
elif type -p crux >/dev/null 2>&1; then elif type -p crux >/dev/null 2>&1; then
distro="$(crux)" distro="$(crux)"
case "$distro_shorthand" in
"on") distro="${distro//version}" ;;
"tiny") distro="${distro//version*}" ;;
esac
else else
distro="$(awk -F 'NAME=' '/^NAME=/ {printf $2}' /etc/*ease)" # Workarounds are included in every shorthand option
distro="${distro//\"}" case "$distro_shorthand" in
"on")
distro="$(awk -F'=' '/^NAME|VERSION_ID=/ {print $2}' /etc/*ease)"
[ -z "$distro" ] && distro="$(awk -F'=' '/^DISTRIB_ID|DISTRIB_RELEASE=/ {print $2}' /etc/openwrt_release)"
;;
# Workaround for distros that store the value differently. "tiny")
[ -z "$distro" ] && distro="$(awk -F 'TAILS_PRODUCT_NAME="|"' '/^TAILS_PRODUCT_NAME=/ {printf $2}' /etc/*ease)" distro="$(awk -F'=' '/^NAME=/ {print $2}' /etc/*ease)"
[ -z "$distro" ] && distro="$(awk -F'=' '/^TAILS_PRODUCT_NAME=/ {print $2}' /etc/*ease)"
[ -z "$distro" ] && distro="$(awk -F'=' '/^DISTRIB_ID=/ {print $2}' /etc/openwrt_release)"
;;
*)
distro="$(awk -F'=' '/^PRETTY_NAME=/ {print $2}' /etc/*ease)"
[ -z "$distro" ] && distro="$(awk -F'=' '{print $2}' /etc/*ease)"
[ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease)" [ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease)"
[ -z "$distro" ] && distro="$(awk -F "'" '/^DISTRIB_DESCRIPTION/ {print $2}' /etc/openwrt_release)" [ -z "$distro" ] && distro="$(awk -F'=' '/^DISTRIB_DESCRIPTION=/ {print $2}' /etc/openwrt_release)"
;;
esac
fi fi
distro="${distro//\"}"
distro="${distro//\'}"
;; ;;
"Mac OS X") "Mac OS X")
@ -2771,8 +2790,8 @@ usage() { cat << EOF
--cpu_shorthand type Shorten the output of CPU --cpu_shorthand type Shorten the output of CPU
Possible values: name, speed, tiny, on, off Possible values: name, speed, tiny, on, off
--cpu_cores on/off Whether or not to display the number of CPU cores --cpu_cores on/off Whether or not to display the number of CPU cores
--distro_shorthand on/off Shorten the output of distro --distro_shorthand on/off Shorten the output of distro (tiny, on, off)
NOTE: This is only possible on Linux with lsb_release NOTE: This is only possible on Linux
--kernel_shorthand on/off Shorten the output of kernel --kernel_shorthand on/off Shorten the output of kernel
--uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) --uptime_shorthand on/off Shorten the output of uptime (tiny, on, off)
--refresh_rate on/off Whether to display the refresh rate of each monitor --refresh_rate on/off Whether to display the refresh rate of each monitor

View File

@ -45,9 +45,9 @@ Possible values: name, speed, tiny, on, off
Whether or not to display the number of CPU cores Whether or not to display the number of CPU cores
.TP .TP
.B \--distro_shorthand 'on/off' .B \--distro_shorthand 'on/off'
Shorten the output of distro Shorten the output of distro (tiny, on, off)
.br .br
NOTE: This is only possible on Linux with lsb_release NOTE: This is only possible on Linux
.TP .TP
.B \--kernel_shorthand 'on/off' .B \--kernel_shorthand 'on/off'
Shorten the output of kernel Shorten the output of kernel