From 0e8f6637dcad09578a6bb33e1a15ac1036e5380b Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 17:41:35 +1100 Subject: [PATCH 01/13] General: Cleanup main --- neofetch | 48 ++++++++++++++++++------------------------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/neofetch b/neofetch index c9271f09..08c3a03f 100755 --- a/neofetch +++ b/neofetch @@ -1943,6 +1943,10 @@ get_image_backend() { "ascii") get_ascii 2>/dev/null ;; esac + + # Set cursor position next to ascii art. + [[ "$image_backend" != "off" ]] && \ + printf "%b" "\033[$((${lines:-0} - ${prompt_loc:-0}))A\033[9999999D" } get_ascii() { @@ -2953,12 +2957,15 @@ get_term_padding() { } dynamic_prompt() { - if [[ "$image_backend" == "image" ]]; then - get_term_padding 2>/dev/null + case "$image_backend" in + "image") + get_term_padding 2>/dev/null - # Calculate image height in terminal cells. - lines="$(((height + (${border:-0} * 2) + ${yoffset:-0}) / font_height))" - fi + # Calculate image height in terminal cells. + lines="$(((height + (${border:-0} * 2) + ${yoffset:-0}) / font_height))" + ;; + "off") return ;; + esac # If the info is higher than the ascii/image place the prompt # based on the info height instead of the ascii/image height. @@ -3336,42 +3343,23 @@ main() { get_bold get_distro_colors - # Restore cursor and clear screen on ctrl+c - trap 'printf "\033[?25h"; clear; exit' 2 - # If the script exits for any reason, unhide the cursor. - trap 'printf "\033[?25h"' EXIT + trap 'printf "\033[?25h\033[?7h"' EXIT # Hide the cursor and disable line wrap printf "\033[?25l\033[?7l" get_image_backend - - if [[ "$image_backend" != "off" ]]; then - # Set cursor position next to ascii art - printf "%b" "\033[$((${lines:-0} - ${prompt_loc:-0}))A" - - # Reset horizontal cursor position - printf "\033[9999999D" - fi - - # Print the info old_functions get_cache_dir print_info 2>/dev/null + dynamic_prompt - # Prompt calculation - if [[ "$image_backend" != "off" ]]; then - dynamic_prompt - - # w3m-img: Draw the image a second time to fix - # rendering issues in specific terminal emulators. - [[ "$image_backend" == "image" && "$image_program" == "w3m" ]] && display_image - fi - - # Re-enable line wrap - printf "%b" "\033[?7h" + # w3m-img: Draw the image a second time to fix + # rendering issues in specific terminal emulators. + [[ "$image_backend" == "image" && "$image_program" == "w3m" ]] && display_image + # Take a screenshot [[ "$scrot" == "on" ]] && take_scrot # Show error messages From 9be91cd8e3ad041c3c067a33d0ee104f6f375438 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 17:59:54 +1100 Subject: [PATCH 02/13] Scrot: Quote unquoted var --- neofetch | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/neofetch b/neofetch index c9271f09..2a8be65d 100755 --- a/neofetch +++ b/neofetch @@ -88,6 +88,7 @@ get_distro() { else # Source the os-release file for file in /etc/os-release /usr/lib/os-release /etc/*release /usr/lib/*release; do + # shellcheck disable=1090 source "$file" && break done @@ -2392,22 +2393,22 @@ scrot_program() { # falling back to OS specific screenshot tools. if [[ -n "$DISPLAY" ]]; then if [[ "$scrot_cmd" != "auto" ]] && type -p "$scrot_cmd" >/dev/null; then - scrot_program="$scrot_cmd" + scrot_program=("$scrot_cmd") elif type -p scrot >/dev/null; then - scrot_program="scrot" + scrot_program=(scrot) elif type -p maim >/dev/null; then - scrot_program="maim" + scrot_program=(maim) elif type -p import >/dev/null; then - scrot_program="import -window root" + scrot_program=(import -window root) elif type -p imlib2_grab >/dev/null; then - scrot_program="imlib2_grab" + scrot_program=(imlib2_grab) elif type -p gnome-screenshot >/dev/null; then - scrot_program="gnome-screenshot -f" + scrot_program=(gnome-screenshot -f) else err "Scrot: No screen capture tool found." @@ -2415,15 +2416,15 @@ scrot_program() { fi else case "$os" in - "Mac OS X") scrot_program="screencapture -S" ;; - "Haiku") scrot_program="screenshot -s" ;; + "Mac OS X") scrot_program=(screencapture -S) ;; + "Haiku") scrot_program=(screenshot -s) ;; esac fi # Take the scrot. - $scrot_program "$1" + "${scrot_program[@]}" "$1" - err "Scrot: Screen captured using $scrot_program" + err "Scrot: Screen captured using ${scrot_program[0]}" } # TEXT FORMATTING From a6e2bc9f8af64e4ec1798e8976195b999e5e28a2 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 18:00:53 +1100 Subject: [PATCH 03/13] General: Remove test comment --- neofetch | 1 - 1 file changed, 1 deletion(-) diff --git a/neofetch b/neofetch index 2a8be65d..25280ed5 100755 --- a/neofetch +++ b/neofetch @@ -88,7 +88,6 @@ get_distro() { else # Source the os-release file for file in /etc/os-release /usr/lib/os-release /etc/*release /usr/lib/*release; do - # shellcheck disable=1090 source "$file" && break done From c0355cea99c91f2524ce8a27b4466c24f518a3cb Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 18:23:25 +1100 Subject: [PATCH 04/13] Song: [cmus] Simplify block and fix artistsort bug --- neofetch | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/neofetch b/neofetch index c9271f09..58fd1d54 100755 --- a/neofetch +++ b/neofetch @@ -1137,11 +1137,9 @@ get_song() { "cmus"*) IFS=$'\n' - song=($(cmus-remote -Q | grep -F -e "tag artist" -e "tag title" -e "status" | sort)) - state="${song[0]/status }" - artist="${song[1]/tag artist }" - title="${song[2]/tag title }" - song="${artist/tag title } - ${title/tag artist }" + cmus=($(cmus-remote -Q | grep -F -e "tag artist " -e "tag title" -e "status" | sort)) + song="${cmus[1]/tag artist } - ${cmus[2]/tag title }" + state="${cmus[0]/status }" ;; "mocp"*) From 8856e29a0953da3a64f803bcfa4ccf62fb8ea3fe Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 23:54:38 +1100 Subject: [PATCH 05/13] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8482c1a8..fc3950bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques **Song**
- Simplify state detection. +- [cmus] Simplify block and fix `artistsort` bug **Color Blocks**
From 82584083a3e1d9bda3e1fe1a71078dd6e2beb384 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 23:54:48 +1100 Subject: [PATCH 06/13] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc3950bc..1dea9926 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any questions, issues or ideas feel free to join the irc channel and I'll be happy to assist you. I know that we've already got the gitter chat but hopefully this makes things easier for those without a github account. :) -+[![Freenode](https://img.shields.io/badge/%23neofetch-%20on%20Freenode-brightgreen.svg)](http://irc.lc/freenode/neofetch) +[![Freenode](https://img.shields.io/badge/%23neofetch-%20on%20Freenode-brightgreen.svg)](http://irc.lc/freenode/neofetch) ## General From 62208c59b233b2f03f2c8c14396d1d3f636a1cf6 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 23:55:56 +1100 Subject: [PATCH 07/13] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dea9926..0d99d721 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,3 +44,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques - Fixed bug causing macOS ascii art to be used on other Operating Systems. - Display warning about 'ascii' being the new default mode. + +## Screenshot + +- Use arrays for `$scrot_program` From 4ef8c36fb55e91a3e63782c74131ea2722aeb416 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 23:56:14 +1100 Subject: [PATCH 08/13] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d99d721..29fa39a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ - **[@konimex](https://github.com/konimex)** + ## IRC Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any questions, issues or ideas feel free to join the irc channel and I'll be happy to assist you. I know that we've already got the gitter chat but hopefully this makes things easier for those without a github account. :) @@ -35,6 +36,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques - Use start++ instead of adding it manually after case. **[@konimex](https://github.com/konimex)** + ## Images - [iTerm2] Fixed blank images. @@ -45,6 +47,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques - Fixed bug causing macOS ascii art to be used on other Operating Systems. - Display warning about 'ascii' being the new default mode. + ## Screenshot - Use arrays for `$scrot_program` From eb7eff298daf26b80145d9a1a7bf18c2e15ea923 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 12 Dec 2016 23:57:28 +1100 Subject: [PATCH 09/13] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29fa39a0..cbc4a3a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques - Optimize usage of get_de(), get_wm() and get_term(). - We were calling these multiple times, we now check to see if they were run previously. - Optimize info caching, only check for cache files in scripts that use caching. +- Cleanup `main()`. ## Info From 6dbdaa4a63fcde231d015d8761d5d943d9431401 Mon Sep 17 00:00:00 2001 From: Jorge Gonzalez Date: Mon, 12 Dec 2016 16:40:03 -0500 Subject: [PATCH 10/13] Fix always charging bug --- neofetch | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/neofetch b/neofetch index 9b6add40..7419c5e2 100755 --- a/neofetch +++ b/neofetch @@ -1709,7 +1709,11 @@ get_battery() { "Mac OS X") battery="$(pmset -g batt | grep -o '[0-9]*%')" - battery_state="$(pmset -g batt | awk 'NR==2 {print $3}')" + state="$(pmset -g batt | awk '/;/ {print $4}')" + if [ "$state" == "charging;" ]; + then + battery_state="charging" + fi ;; "Windows") From da251b8bc92b9adfac54846e4194ce77291786a0 Mon Sep 17 00:00:00 2001 From: Jorge Gonzalez Date: Mon, 12 Dec 2016 17:57:49 -0500 Subject: [PATCH 11/13] Change to one-line if statement --- neofetch | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/neofetch b/neofetch index 7419c5e2..09b9fdf0 100755 --- a/neofetch +++ b/neofetch @@ -1710,10 +1710,7 @@ get_battery() { "Mac OS X") battery="$(pmset -g batt | grep -o '[0-9]*%')" state="$(pmset -g batt | awk '/;/ {print $4}')" - if [ "$state" == "charging;" ]; - then - battery_state="charging" - fi + [[ "$state" == "charging;" ]] && battery_state="charging" ;; "Windows") From 0b96f668f2ef5c87e8d8bfee1552cba8c6f87f46 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 13 Dec 2016 10:20:58 +1100 Subject: [PATCH 12/13] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbc4a3a8..e27af62b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## Contributors - **[@konimex](https://github.com/konimex)** +- **[@iandrewt](https://github.com/iandrewt)** +- **[@jorgegonzalez](https://github.com/jorgegonzalez)** ## IRC @@ -33,6 +35,10 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques - Simplify state detection. - [cmus] Simplify block and fix `artistsort` bug +**Battery**
+ +- [MacOS] Fix issue where battery always appears as charging. **[@jorgegonzalez](https://github.com/jorgegonzalez)** + **Color Blocks**
- Use start++ instead of adding it manually after case. **[@konimex](https://github.com/konimex)** From f78c65d790f710b988ce6487b18eaf28f6bce642 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Tue, 13 Dec 2016 10:21:12 +1100 Subject: [PATCH 13/13] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e27af62b..476e3394 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,7 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques **Battery**
-- [MacOS] Fix issue where battery always appears as charging. **[@jorgegonzalez](https://github.com/jorgegonzalez)** +- [MacOS] Fixed issue where battery always appears as charging. **[@jorgegonzalez](https://github.com/jorgegonzalez)** **Color Blocks**