From 207af2ad532e8576fb50b0631adf914fb763197d Mon Sep 17 00:00:00 2001 From: Dylan Date: Sat, 30 Jan 2016 22:41:58 +1100 Subject: [PATCH] Added birthday function --- 1.1.md | 4 ++++ README.md | 2 ++ config/config | 13 +++++++++++++ fetch | 35 +++++++++++++++++++++++++++++++---- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/1.1.md b/1.1.md index 91ebe072..02b6e21a 100644 --- a/1.1.md +++ b/1.1.md @@ -57,6 +57,10 @@ systems it isn't packaged for yet! - Mac OS X: Added wired memory to memory usage. +**Birthday:** + +- Added `birthday` which prints the age of tyour OS + ### Image diff --git a/README.md b/README.md index 4f356770..6b5040ff 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,8 @@ alias fetch2="fetch \ --gtk3 on/off Enable/Disable gtk3 theme/icons output --shell_path on/off Enable/Disable showing \$SHELL path --shell_version on/off Enable/Disable showing \$SHELL version + --birthday_shorthand Shorten the output of birthday + --birthday_time Enable/Disable showing the time in birthday output Text Colors: --colors 1 2 3 4 5 6 Change the color of text diff --git a/config/config b/config/config index e5049f53..48f0b147 100644 --- a/config/config +++ b/config/config @@ -11,6 +11,7 @@ export LANGUAGE=C # Info Options {{{ + # Info # See this wiki page for more info: # https://github.com/dylanaraps/fetch/wiki/Customizing-Info @@ -32,6 +33,7 @@ printinfo () { info "GPU" gpu info "Memory" memory + info "Birthday" birthday # info "Font" gtkfont # info "Disk" disk # info "Resolution" resolution @@ -108,6 +110,17 @@ gtk2="on" gtk3="on" +# Birthday + +# Whether to show a long pretty output +# or a shortened one +# --birthday_shorthand on/off +birthday_shorthand="off" + +# Whether to show the time in the output +# --birthday_time on/off +birthday_time="on" + # Color Blocks # Color block range diff --git a/fetch b/fetch index 574a192e..56e8b39f 100755 --- a/fetch +++ b/fetch @@ -53,11 +53,11 @@ printinfo () { info "GPU" gpu info "Memory" memory - # info "Birthday" birthday # info "Font" gtkfont # info "Disk" disk # info "Resolution" resolution # info "Song" song + # info "Birthday" birthday # info "Visual Style" visualstyle info linebreak @@ -130,6 +130,17 @@ gtk2="on" gtk3="on" +# Birthday + +# Whether to show a long pretty output +# or a shortened one +# --birthday_shorthand on/off +birthday_shorthand="off" + +# Whether to show the time in the output +# --birthday_time on/off +birthday_time="on" + # Color Blocks # Color block range @@ -1179,14 +1190,12 @@ getdisk () { getbirthday () { case "$os" in - "Linux") + "Linux" | *"BSD") birthday="$(ls -alct --full-time / | awk '/lost\+found/ {printf $6 " " $7}')" - birthday=${birthday%:*} ;; "Mac OS X") birthday="$(ls -alctT /var/log/CDIS.custom | tail -1 | awk '{printf $6 " " $7 " " $9 " " $8}')" - birthday=${birthday%:*} ;; *) @@ -1194,6 +1203,20 @@ getbirthday () { ;; esac + + # Strip seconds from time output + birthday=${birthday%:*} + + # Pretty output + if [ "$birthday_shorthand" == "off" ]; then + birthday="$(date -d"$birthday" "+%a %d %b %Y %l:%M %p")" + birthday=${birthday/ } + fi + + # Toggle showing the time + if [ "$birthday_time" == "off" ]; then + birthday=${birthday/??:??*} + fi } # }}} @@ -1856,6 +1879,8 @@ usage () { cat << EOF --gtk3 on/off Enable/Disable gtk3 theme/icons output --shell_path on/off Enable/Disable showing \$SHELL path --shell_version on/off Enable/Disable showing \$SHELL version + --birthday_shorthand Shorten the output of birthday + --birthday_time Enable/Disable showing the time in birthday output Text Colors: --colors 1 2 3 4 5 6 Change the color of text @@ -1953,6 +1978,8 @@ while [ "$1" ]; do --gtk3) gtk3="$2" ;; --shell_path) shell_path="$2" ;; --shell_version) shell_version="$2" ;; + --birthday_shorthand) birthday_shorthand="$2" ;; + --birthday_time) birthday_time="$2" ;; # Text Colors --colors) title_color=$2