Merge pull request #323 from konimex/lsb

Added distro_shorthand to simplify lsb_release output
This commit is contained in:
Dylan Araps 2016-08-30 19:53:26 +10:00 committed by GitHub
commit 0a56836343
3 changed files with 17 additions and 1 deletions

View file

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

View file

@ -119,7 +119,11 @@ getdistro() {
case "$os" in case "$os" in
"Linux" ) "Linux" )
if type -p lsb_release >/dev/null 2>&1; then if type -p lsb_release >/dev/null 2>&1; then
distro="$(lsb_release -d 2>/dev/null | awk -F ':' '/Description/ {printf $2}')" case "$distro_shorthand" in
"on") distro="$(lsb_release -sir 2>/dev/null)" ;;
"off") distro="$(lsb_release -sd 2>/dev/null)"
distro="${distro//\"}" ;;
esac
elif type -p guix >/dev/null 2>&1; then elif type -p guix >/dev/null 2>&1; then
distro="GuixSD" distro="GuixSD"
@ -2767,6 +2771,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
NOTE: This is only possible on Linux with lsb_release
--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
@ -2889,6 +2895,7 @@ getargs() {
--osx_codename) osx_codename="$2" ;; --osx_codename) osx_codename="$2" ;;
--cpu_cores) cpu_cores="$2" ;; --cpu_cores) cpu_cores="$2" ;;
--speed_type) speed_type="$2" ;; --speed_type) speed_type="$2" ;;
--distro_shorthand) distro_shorthand="$2" ;;
--kernel_shorthand) kernel_shorthand="$2" ;; --kernel_shorthand) kernel_shorthand="$2" ;;
--uptime_shorthand) uptime_shorthand="$2" ;; --uptime_shorthand) uptime_shorthand="$2" ;;
--cpu_shorthand) cpu_shorthand="$2" ;; --cpu_shorthand) cpu_shorthand="$2" ;;

View file

@ -44,6 +44,11 @@ Possible values: name, speed, tiny, on, off
.B \--cpu_cores 'on/off' .B \--cpu_cores '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'
Shorten the output of distro
.br
NOTE: This is only possible on Linux with lsb_release
.TP
.B \--kernel_shorthand 'on/off' .B \--kernel_shorthand 'on/off'
Shorten the output of kernel Shorten the output of kernel
.TP .TP