From 6698463df67b992acd94c58df9d8cd213d7e6d9f Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 11:20:10 +1100 Subject: [PATCH 01/17] Birthday: Remove 'date' usage and calclulate date manually --- config/config | 34 --------------------- neofetch | 81 +++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 59 insertions(+), 56 deletions(-) diff --git a/config/config b/config/config index 9384d597..94a257fd 100644 --- a/config/config +++ b/config/config @@ -292,40 +292,6 @@ public_ip_host="http://ident.me" song_shorthand="off" -# Birthday - - -# Shorten the output of the Birthday functon. -# -# Default: 'off' -# Values: 'on', 'off' -# Flag: --birthday_shorthand -# Supports: 'off' doesn't work on OpenBSD and NetBSD. -# -# Example: -# on: 'Thu 14 Apr 2016 11:50 PM' -# off: '2016-04-14 23:50:55' -birthday_shorthand="off" - -# Whether to show the time in the output -# -# Default: 'on' -# Values: 'on', 'off' -# Flag: --birthday_time -# -# Example: -# on: 'Thu 14 Apr 2016 11:50 PM' -# off: 'Thu 14 Apr 2016' -birthday_time="on" - -# Date format to use when printing birthday -# -# Default: '+%a %d %b %Y %l:%M %p' -# Values: 'date format' -# Flag: --birthday_format -birthday_format="+%a %d %b %Y %l:%M %p" - - # Text Colors diff --git a/neofetch b/neofetch index f4551dab..2e33d4b6 100755 --- a/neofetch +++ b/neofetch @@ -317,7 +317,7 @@ get_uptime() { boot="${boot/,*}" # Get current date in seconds - now="$(date +%s)" + now="$(printf "%(%s)T")" seconds="$((now - boot))" ;; @@ -1730,7 +1730,6 @@ get_birthday() { case "$os" in "Linux" | "GNU" | "iPhone OS") birthday="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')" - date_cmd="$(date -d"$birthday" "$birthday_format")" ;; "Mac OS X") @@ -1757,7 +1756,6 @@ get_birthday() { "FreeBSD"*) birthday="$(ls -alctT /etc/hostid | awk '{printf $6 " " $7 " " $9 " " $8}')" - date_cmd="$(date -j -f "%b %d %Y" "$birthday" "$birthday_format")" ;; "NetBSD"* | "DragonFly"*) @@ -1769,30 +1767,21 @@ get_birthday() { "Windows") birthday="$(ls -alct --full-time /cygdrive/c/Windows/explorer.exe | awk '{printf $8 " " $9}')" - date_cmd="$(date -d"$birthday" "$birthday_format")" ;; "Solaris") birthday="$(ls -alct --full-time /var/sadm/system/logs/install_log | awk '{printf $6 " " $7}')" - date_cmd="$(date -d"$birthday" "$birthday_format")" ;; "Haiku") birthday="$(ls -alctd --full-time /boot | awk '{printf $6 " " $7}')" - date_cmd="$(date -d"$birthday" "$birthday_format")" ;; esac - # Strip seconds from time output - birthday="${birthday/:?? / }" - - # Pretty output - [[ "$birthday_shorthand" == "off" ]] && \ - birthday="${date_cmd//+( )/ }" - - # Toggle showing the time - [[ "$birthday_time" == "off" ]] && \ - birthday="${birthday/??:??*}" + birthday="${birthday%\.*}" + birthday="${birthday//-/ }" + birthday=($birthday) + birthday="$(convert_time "${birthday[@]}")" } get_cols() { @@ -2938,6 +2927,60 @@ cache_uname() { machine_arch="${uname[2]}" } +convert_time() { + # Convert ls timestamp to 'Tue 06 Dec 2016 4:58 PM' format. + year="$1" + day="$3" + + # Split time into hours/minutesr + time="${4%\:*}" + hour="${time/:*}" + min="${time/${hour}}" + + # Get month. (Month code is used for day of week) + case "$2" in + 1) month="Jan"; month_code="0" ;; + 2) month="Feb"; month_code="3" ;; + 3) month="Mar"; month_code="3" ;; + 4) month="Apr"; month_code="6" ;; + 5) month="May"; month_code="1" ;; + 6) month="Jun"; month_code="4" ;; + 7) month="Jul"; month_code="6" ;; + 8) month="Aug"; month_code="2" ;; + 9) month="Sep"; month_code="5" ;; + 10) month="Oct"; month_code="0" ;; + 11) month="Nov"; month_code="3" ;; + 12) month="Dec"; month_code="5" ;; + esac + + # Get leap year. + [[ "$((year % 4))" == 0 && "$((year % 100))" != 0 || "$((year % 400))" == 0 ]] && \ + [[ "$month" =~ (Jan|Feb) ]] && \ + leap_code="1" + + # Calculate day of week. + year_code="$((${year/??} + $((${year/??} / 4)) % 7))" + week_day="$(($((year_code + month_code + 6 + day - ${leap_code:-0})) % 7))" + + case "$week_day" in + 0) week_day="Sun" ;; + 1) week_day="Mon" ;; + 2) week_day="Tue" ;; + 3) week_day="Wed" ;; + 4) week_day="Thu" ;; + 5) week_day="Fri" ;; + 6) week_day="Sat" ;; + esac + + # Convert 24 hour time to 12 hour time + AM/PM + case "$hour" in + 0[0-9] | 1[0-2]) time="${hour}${min} AM" ;; + *) time="$((hour - 12))${min} PM" ;; + esac + + printf "%s" "$week_day $day $month $year $time" +} + # FINISH UP usage() { printf "%s" "\ @@ -2996,9 +3039,6 @@ INFO --shell_version on/off Enable/Disable showing \$SHELL version --ip_host url URL to query for public IP --song_shorthand on/off Print the Artist/Title on seperate lines - --birthday_shorthand on/off Shorten the output of birthday - --birthday_time on/off Enable/Disable showing the time in birthday output - --birthday_format format Format the birthday output. (Uses 'date' cmd format) TEXT FORMATTING @@ -3167,9 +3207,6 @@ get_args() { "--shell_version") shell_version="$2" ;; "--ip_host") public_ip_host="$2" ;; "--song_shorthand") song_shorthand="$2" ;; - "--birthday_shorthand") birthday_shorthand="$2" ;; - "--birthday_time") birthday_time="$2" ;; - "--birthday_format") birthday_format="$2" ;; "--disable") for func in "$@"; do case "$func" in From 708beb1716c9a08ea0706d2341b0dc63f8146bd5 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 11:27:53 +1100 Subject: [PATCH 02/17] Birthday: Remove macOS substitutions --- neofetch | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/neofetch b/neofetch index 2e33d4b6..2d6745aa 100755 --- a/neofetch +++ b/neofetch @@ -1734,24 +1734,12 @@ get_birthday() { "Mac OS X") birthday="$(ls -lUT /var/log/install.log | awk '{printf $6 " " $7 " " $9 " " $8}')" - - # Split the string into Date + time - time="${birthday/*???? }" - birthday="${birthday/$time}" - - case "${time/:*}" in - 0? | 10 | 11) time+=" AM" ;; - *) time+=" PM" ;; - esac - birthday+="$time" - birthday_shorthand="on" ;; "BSD") case "$kernel_name" in "OpenBSD"* | "Bitrig"*) birthday="$(ls -alctT / | awk '/lost\+found/ {printf $6 " " $7 " " $9 " " $8}')" - birthday_shorthand="on" ;; "FreeBSD"*) @@ -1760,7 +1748,6 @@ get_birthday() { "NetBSD"* | "DragonFly"*) birthday="$(ls -alctT /etc/defaults/rc.conf | awk '{printf $6 " " $7 " " $9 " " $8}')" - birthday_shorthand="on" ;; esac ;; From 14610a992c85979d114e1a625a013e2738743738 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 12:07:01 +1100 Subject: [PATCH 03/17] Birthday: Merge macOS with BSD --- neofetch | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/neofetch b/neofetch index 2d6745aa..e0471ee6 100755 --- a/neofetch +++ b/neofetch @@ -1736,20 +1736,26 @@ get_birthday() { birthday="$(ls -lUT /var/log/install.log | awk '{printf $6 " " $7 " " $9 " " $8}')" ;; - "BSD") + "BSD" | "Mac OS X") case "$kernel_name" in + "Darwin") + birthday_file="/var/log/install.log" + ;; + "OpenBSD"* | "Bitrig"*) - birthday="$(ls -alctT / | awk '/lost\+found/ {printf $6 " " $7 " " $9 " " $8}')" + birthday_file="/" ;; "FreeBSD"*) - birthday="$(ls -alctT /etc/hostid | awk '{printf $6 " " $7 " " $9 " " $8}')" + birthday_file="/etc/hostid" ;; "NetBSD"* | "DragonFly"*) - birthday="$(ls -alctT /etc/defaults/rc.conf | awk '{printf $6 " " $7 " " $9 " " $8}')" + birthday_file="/etc/defaults/rc.conf" ;; esac + + birthday="$(ls -alctT "$birthday_file" | awk '{printf $6 " " $7 " " $9 " " $8}')" ;; "Windows") @@ -1765,8 +1771,8 @@ get_birthday() { ;; esac - birthday="${birthday%\.*}" birthday="${birthday//-/ }" + birthday="${birthday%:*}" birthday=($birthday) birthday="$(convert_time "${birthday[@]}")" } @@ -2919,25 +2925,24 @@ convert_time() { year="$1" day="$3" - # Split time into hours/minutesr - time="${4%\:*}" - hour="${time/:*}" - min="${time/${hour}}" + # Split time into hours/minutes + hour="${4/:*}" + min="${4/${hour}}" # Get month. (Month code is used for day of week) case "$2" in - 1) month="Jan"; month_code="0" ;; - 2) month="Feb"; month_code="3" ;; - 3) month="Mar"; month_code="3" ;; - 4) month="Apr"; month_code="6" ;; - 5) month="May"; month_code="1" ;; - 6) month="Jun"; month_code="4" ;; - 7) month="Jul"; month_code="6" ;; - 8) month="Aug"; month_code="2" ;; - 9) month="Sep"; month_code="5" ;; - 10) month="Oct"; month_code="0" ;; - 11) month="Nov"; month_code="3" ;; - 12) month="Dec"; month_code="5" ;; + 1 | "Jan") month="Jan"; month_code="0" ;; + 2 | "Feb") month="Feb"; month_code="3" ;; + 3 | "Mar") month="Mar"; month_code="3" ;; + 4 | "Apr") month="Apr"; month_code="6" ;; + 5 | "May") month="May"; month_code="1" ;; + 6 | "Jun") month="Jun"; month_code="4" ;; + 7 | "Jul") month="Jul"; month_code="6" ;; + 8 | "Aug") month="Aug"; month_code="2" ;; + 9 | "Sep") month="Sep"; month_code="5" ;; + 10 | "Oct") month="Oct"; month_code="0" ;; + 11 | "Nov") month="Nov"; month_code="3" ;; + 12 | "Dec") month="Dec"; month_code="5" ;; esac # Get leap year. From 382392240ca71b720172e832aa00224b4236e7b6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 12:07:44 +1100 Subject: [PATCH 04/17] Birthday: Remove old macOS block --- neofetch | 4 ---- 1 file changed, 4 deletions(-) diff --git a/neofetch b/neofetch index e0471ee6..f46b1dc3 100755 --- a/neofetch +++ b/neofetch @@ -1732,10 +1732,6 @@ get_birthday() { birthday="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')" ;; - "Mac OS X") - birthday="$(ls -lUT /var/log/install.log | awk '{printf $6 " " $7 " " $9 " " $8}')" - ;; - "BSD" | "Mac OS X") case "$kernel_name" in "Darwin") From bb7f4ac26bc2defd84979bfac049a3d93fb04929 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 12:10:05 +1100 Subject: [PATCH 05/17] Birthday: Swap BSD / macOS fields --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index f46b1dc3..5a065e19 100755 --- a/neofetch +++ b/neofetch @@ -1751,7 +1751,7 @@ get_birthday() { ;; esac - birthday="$(ls -alctT "$birthday_file" | awk '{printf $6 " " $7 " " $9 " " $8}')" + birthday="$(ls -alctT "$birthday_file" | awk '{printf $9 " " $7 " " $6 " " $8}')" ;; "Windows") From ff0d9e9e733d82f34af3b4bb0ac879fa6c7d5647 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 12:22:18 +1100 Subject: [PATCH 06/17] Birthday: Fix BSD field order --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 5a065e19..e2d0c632 100755 --- a/neofetch +++ b/neofetch @@ -1751,7 +1751,7 @@ get_birthday() { ;; esac - birthday="$(ls -alctT "$birthday_file" | awk '{printf $9 " " $7 " " $6 " " $8}')" + birthday="$(ls -alctT "$birthday_file" | awk '{printf $9 " " $6 " " $7 " " $8}')" ;; "Windows") From 62a87b7bf65e1a8fe5ac7dfe3836b1ac37addc7d Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 12:28:11 +1100 Subject: [PATCH 07/17] Birthday: [BSD] Fix openBSD --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index e2d0c632..21c21d99 100755 --- a/neofetch +++ b/neofetch @@ -1751,7 +1751,7 @@ get_birthday() { ;; esac - birthday="$(ls -alctT "$birthday_file" | awk '{printf $9 " " $6 " " $7 " " $8}')" + birthday="$(ls -alctT "$birthday_file" | awk '{printf $9 " " $6 " " $7 " " $8 " "}')" ;; "Windows") From 27e634fc0c039901f028c271210ed2cc8aa54f6a Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 12:33:42 +1100 Subject: [PATCH 08/17] Birthday: Fix Month matching on Windows --- neofetch | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/neofetch b/neofetch index 21c21d99..4df60ccf 100755 --- a/neofetch +++ b/neofetch @@ -2927,18 +2927,18 @@ convert_time() { # Get month. (Month code is used for day of week) case "$2" in - 1 | "Jan") month="Jan"; month_code="0" ;; - 2 | "Feb") month="Feb"; month_code="3" ;; - 3 | "Mar") month="Mar"; month_code="3" ;; - 4 | "Apr") month="Apr"; month_code="6" ;; - 5 | "May") month="May"; month_code="1" ;; - 6 | "Jun") month="Jun"; month_code="4" ;; - 7 | "Jul") month="Jul"; month_code="6" ;; - 8 | "Aug") month="Aug"; month_code="2" ;; - 9 | "Sep") month="Sep"; month_code="5" ;; - 10 | "Oct") month="Oct"; month_code="0" ;; - 11 | "Nov") month="Nov"; month_code="3" ;; - 12 | "Dec") month="Dec"; month_code="5" ;; + 1 | 01 | "Jan") month="Jan"; month_code="0" ;; + 2 | 02 | "Feb") month="Feb"; month_code="3" ;; + 3 | 03 | "Mar") month="Mar"; month_code="3" ;; + 4 | 04 | "Apr") month="Apr"; month_code="6" ;; + 5 | 05 | "May") month="May"; month_code="1" ;; + 6 | 06 | "Jun") month="Jun"; month_code="4" ;; + 7 | 07 | "Jul") month="Jul"; month_code="6" ;; + 8 | 08 | "Aug") month="Aug"; month_code="2" ;; + 9 | 09 | "Sep") month="Sep"; month_code="5" ;; + 10 | "Oct") month="Oct"; month_code="0" ;; + 11 | "Nov") month="Nov"; month_code="3" ;; + 12 | "Dec") month="Dec"; month_code="5" ;; esac # Get leap year. From 89f7c2210d5dba43c8c3eae2066a8988650134b0 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 13:12:18 +1100 Subject: [PATCH 09/17] Uptime: Revert date removal --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 4df60ccf..b1b4998a 100755 --- a/neofetch +++ b/neofetch @@ -317,7 +317,7 @@ get_uptime() { boot="${boot/,*}" # Get current date in seconds - now="$(printf "%(%s)T")" + now="$(date +%s)" seconds="$((now - boot))" ;; From bfdca24bbdc2a50ccc23339124357a224de53d60 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 13:33:50 +1100 Subject: [PATCH 10/17] Birthday: Fix macOS birthday command --- neofetch | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index b1b4998a..5fd9958a 100755 --- a/neofetch +++ b/neofetch @@ -1732,12 +1732,12 @@ get_birthday() { birthday="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')" ;; - "BSD" | "Mac OS X") - case "$kernel_name" in - "Darwin") - birthday_file="/var/log/install.log" - ;; + "Mac OS X") + birthday="$(ls -lUT /var/log/install.log | awk '{printf $9 " " $6 " " $7 " " $8}')" + ;; + "BSD") + case "$kernel_name" in "OpenBSD"* | "Bitrig"*) birthday_file="/" ;; From 1fa98d7bf1748c48e339114bb2b5920ce5dd3392 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 14:44:04 +1100 Subject: [PATCH 11/17] Birthday: Add sources --- neofetch | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/neofetch b/neofetch index 5fd9958a..2b719a56 100755 --- a/neofetch +++ b/neofetch @@ -2926,6 +2926,7 @@ convert_time() { min="${4/${hour}}" # Get month. (Month code is used for day of week) + # Due to different versions of 'ls', the month can be 1, 01 or Jan. case "$2" in 1 | 01 | "Jan") month="Jan"; month_code="0" ;; 2 | 02 | "Feb") month="Feb"; month_code="3" ;; @@ -2942,11 +2943,13 @@ convert_time() { esac # Get leap year. + # Source: http://stackoverflow.com/questions/725098/leap-year-calculation [[ "$((year % 4))" == 0 && "$((year % 100))" != 0 || "$((year % 400))" == 0 ]] && \ [[ "$month" =~ (Jan|Feb) ]] && \ leap_code="1" # Calculate day of week. + # Source: http://blog.artofmemory.com/how-to-calculate-the-day-of-the-week-4203.html year_code="$((${year/??} + $((${year/??} / 4)) % 7))" week_day="$(($((year_code + month_code + 6 + day - ${leap_code:-0})) % 7))" @@ -2966,6 +2969,7 @@ convert_time() { *) time="$((hour - 12))${min} PM" ;; esac + # Print the birthday. printf "%s" "$week_day $day $month $year $time" } From 828ad2692fb5b8c26f49e305ecf1ac92ef2ae0df Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 14:51:30 +1100 Subject: [PATCH 12/17] Birthday: Handle 00:00 --- neofetch | 1 + 1 file changed, 1 insertion(+) diff --git a/neofetch b/neofetch index 2b719a56..4ee3ef0d 100755 --- a/neofetch +++ b/neofetch @@ -2966,6 +2966,7 @@ convert_time() { # Convert 24 hour time to 12 hour time + AM/PM case "$hour" in 0[0-9] | 1[0-2]) time="${hour}${min} AM" ;; + 00) time="12${min} PM" ;; *) time="$((hour - 12))${min} PM" ;; esac From 1643b4fbd21d23d6175a12e0ec898441a8045bbf Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 14:52:56 +1100 Subject: [PATCH 13/17] Birthday: Properly handle 00 --- neofetch | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/neofetch b/neofetch index 4ee3ef0d..389bbc72 100755 --- a/neofetch +++ b/neofetch @@ -2965,8 +2965,7 @@ convert_time() { # Convert 24 hour time to 12 hour time + AM/PM case "$hour" in - 0[0-9] | 1[0-2]) time="${hour}${min} AM" ;; - 00) time="12${min} PM" ;; + 0[0-9] | 1[0-2]) time="${hour/00/12}${min} AM" ;; *) time="$((hour - 12))${min} PM" ;; esac From 31930d021193edebc0ca044c4ff56f73b0cd1b20 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 14:53:47 +1100 Subject: [PATCH 14/17] Birthday: Fix 12:00 --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 389bbc72..0478fe4e 100755 --- a/neofetch +++ b/neofetch @@ -2965,7 +2965,7 @@ convert_time() { # Convert 24 hour time to 12 hour time + AM/PM case "$hour" in - 0[0-9] | 1[0-2]) time="${hour/00/12}${min} AM" ;; + 0[0-9] | 1[0-1]) time="${hour/00/12}${min} AM" ;; *) time="$((hour - 12))${min} PM" ;; esac From 665e9ceb68d9823e550754f13f961cf89f006a20 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 15:59:07 +1100 Subject: [PATCH 15/17] Birthday: Add back --birthday_time --- config/config | 15 +++++++++++++++ neofetch | 5 +++++ neofetch.1 | 7 +------ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/config/config b/config/config index 94a257fd..c3d2da18 100644 --- a/config/config +++ b/config/config @@ -292,6 +292,21 @@ public_ip_host="http://ident.me" song_shorthand="off" +# Birthday + + +# Whether to show the time in the output +# +# Default: 'on' +# Values: 'on', 'off' +# Flag: --birthday_time +# +# Example: +# on: 'Thu 14 Apr 2016 11:50 PM' +# off: 'Thu 14 Apr 2016' +birthday_time="on" + + # Text Colors diff --git a/neofetch b/neofetch index 0478fe4e..fed90d4b 100755 --- a/neofetch +++ b/neofetch @@ -2969,6 +2969,9 @@ convert_time() { *) time="$((hour - 12))${min} PM" ;; esac + # Toggle showing the time + [[ "$birthday_time" == "off" ]] && unset time + # Print the birthday. printf "%s" "$week_day $day $month $year $time" } @@ -3031,6 +3034,7 @@ INFO --shell_version on/off Enable/Disable showing \$SHELL version --ip_host url URL to query for public IP --song_shorthand on/off Print the Artist/Title on seperate lines + --birthday_time on/off Enable/Disable showing the time in birthday output. TEXT FORMATTING @@ -3199,6 +3203,7 @@ get_args() { "--shell_version") shell_version="$2" ;; "--ip_host") public_ip_host="$2" ;; "--song_shorthand") song_shorthand="$2" ;; + "--birthday_time") birthday_time="$2" ;; "--disable") for func in "$@"; do case "$func" in diff --git a/neofetch.1 b/neofetch.1 index ed786b39..6484a727 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -88,14 +88,9 @@ URL to query for public IP .TP \fB\-\-song_shorthand\fR on/off Print the Artist/Title on seperate lines -.HP -\fB\-\-birthday_shorthand\fR on/off Shorten the output of birthday .TP \fB\-\-birthday_time\fR on/off -Enable/Disable showing the time in birthday output -.TP -\fB\-\-birthday_format\fR format -Format the birthday output. (Uses 'date' cmd format) +Enable/Disable showing the time in birthday output. .PP TEXT FORMATTING .TP From d375aa24d6e7aac02f6732872e9d8dc76d877da5 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 17:38:54 +1100 Subject: [PATCH 16/17] Birthday: Fix bug with 0:00 --- neofetch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neofetch b/neofetch index fed90d4b..12d22239 100755 --- a/neofetch +++ b/neofetch @@ -2965,7 +2965,7 @@ convert_time() { # Convert 24 hour time to 12 hour time + AM/PM case "$hour" in - 0[0-9] | 1[0-1]) time="${hour/00/12}${min} AM" ;; + [0-9] | 0[0-9] | 1[0-1]) time="${hour/00/12}${min} AM" ;; *) time="$((hour - 12))${min} PM" ;; esac From 2490a45293890efd05f36228d8c2d8de33d7da97 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Fri, 16 Dec 2016 18:03:29 +1100 Subject: [PATCH 17/17] Birthday: Rename get_birthday() to get_install_date() --- config/config | 8 ++++---- config/travis | 2 +- neofetch | 38 ++++++++++++++++++++------------------ neofetch.1 | 4 ++-- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/config/config b/config/config index c3d2da18..f89a2d9b 100644 --- a/config/config +++ b/config/config @@ -39,7 +39,7 @@ print_info() { # info "Local IP" local_ip # info "Public IP" public_ip # info "Users" users - # info "Birthday" birthday + # info "Install Date" install_date info line_break info cols @@ -292,19 +292,19 @@ public_ip_host="http://ident.me" song_shorthand="off" -# Birthday +# Install Date # Whether to show the time in the output # # Default: 'on' # Values: 'on', 'off' -# Flag: --birthday_time +# Flag: --install_time # # Example: # on: 'Thu 14 Apr 2016 11:50 PM' # off: 'Thu 14 Apr 2016' -birthday_time="on" +install_time="on" # Text Colors diff --git a/config/travis b/config/travis index 583ae1cd..42431a17 100644 --- a/config/travis +++ b/config/travis @@ -33,7 +33,7 @@ print_info() { info "Local IP" local_ip info "Public IP" public_ip info "Users" users - info "Birthday" birthday + info "Install Date" install_date info line_break info cols diff --git a/neofetch b/neofetch index 12d22239..bfac8b94 100755 --- a/neofetch +++ b/neofetch @@ -1726,51 +1726,51 @@ get_users() { users="${users%\,*}" } -get_birthday() { +get_install_date() { case "$os" in "Linux" | "GNU" | "iPhone OS") - birthday="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')" + install_date="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')" ;; "Mac OS X") - birthday="$(ls -lUT /var/log/install.log | awk '{printf $9 " " $6 " " $7 " " $8}')" + install_date="$(ls -lUT /var/log/install.log | awk '{printf $9 " " $6 " " $7 " " $8}')" ;; "BSD") case "$kernel_name" in "OpenBSD"* | "Bitrig"*) - birthday_file="/" + install_file="/" ;; "FreeBSD"*) - birthday_file="/etc/hostid" + install_file="/etc/hostid" ;; "NetBSD"* | "DragonFly"*) - birthday_file="/etc/defaults/rc.conf" + install_file="/etc/defaults/rc.conf" ;; esac - birthday="$(ls -alctT "$birthday_file" | awk '{printf $9 " " $6 " " $7 " " $8 " "}')" + install_date="$(ls -alctT "$install_file" | awk '{printf $9 " " $6 " " $7 " " $8 " "}')" ;; "Windows") - birthday="$(ls -alct --full-time /cygdrive/c/Windows/explorer.exe | awk '{printf $8 " " $9}')" + install_date="$(ls -alct --full-time /cygdrive/c/Windows/explorer.exe | awk '{printf $8 " " $9}')" ;; "Solaris") - birthday="$(ls -alct --full-time /var/sadm/system/logs/install_log | awk '{printf $6 " " $7}')" + install_date="$(ls -alct --full-time /var/sadm/system/logs/install_log | awk '{printf $6 " " $7}')" ;; "Haiku") - birthday="$(ls -alctd --full-time /boot | awk '{printf $6 " " $7}')" + install_date="$(ls -alctd --full-time /boot | awk '{printf $6 " " $7}')" ;; esac - birthday="${birthday//-/ }" - birthday="${birthday%:*}" - birthday=($birthday) - birthday="$(convert_time "${birthday[@]}")" + install_date="${install_date//-/ }" + install_date="${install_date%:*}" + install_date=($install_date) + install_date="$(convert_time "${install_date[@]}")" } get_cols() { @@ -2883,6 +2883,8 @@ old_functions() { get_publicip() { get_public_ip; publicip="$public_ip"; } get_linebreak() { get_line_break; linebreak="$line_break"; } fi + + get_birthday() { get_install_date; birthday="$install_date"; } } old_options() { @@ -2970,9 +2972,9 @@ convert_time() { esac # Toggle showing the time - [[ "$birthday_time" == "off" ]] && unset time + [[ "$install_time" == "off" ]] && unset time - # Print the birthday. + # Print the install date. printf "%s" "$week_day $day $month $year $time" } @@ -3034,7 +3036,7 @@ INFO --shell_version on/off Enable/Disable showing \$SHELL version --ip_host url URL to query for public IP --song_shorthand on/off Print the Artist/Title on seperate lines - --birthday_time on/off Enable/Disable showing the time in birthday output. + --install_time on/off Enable/Disable showing the time in Install Date output. TEXT FORMATTING @@ -3203,7 +3205,7 @@ get_args() { "--shell_version") shell_version="$2" ;; "--ip_host") public_ip_host="$2" ;; "--song_shorthand") song_shorthand="$2" ;; - "--birthday_time") birthday_time="$2" ;; + "--install_time") install_time="$2" ;; "--disable") for func in "$@"; do case "$func" in diff --git a/neofetch.1 b/neofetch.1 index 6484a727..bf513aef 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -89,8 +89,8 @@ URL to query for public IP \fB\-\-song_shorthand\fR on/off Print the Artist/Title on seperate lines .TP -\fB\-\-birthday_time\fR on/off -Enable/Disable showing the time in birthday output. +\fB\-\-install_time\fR on/off +Enable/Disable showing the time in Install Date output. .PP TEXT FORMATTING .TP