Merge branch 'master' of github.com:dylanaraps/neofetch

This commit is contained in:
Dylan Araps 2016-12-13 11:56:53 +11:00
commit b94f2ef0f9
2 changed files with 49 additions and 47 deletions

View file

@ -1,12 +1,15 @@
## Contributors ## Contributors
- **[@konimex](https://github.com/konimex)** - **[@konimex](https://github.com/konimex)**
- **[@iandrewt](https://github.com/iandrewt)**
- **[@jorgegonzalez](https://github.com/jorgegonzalez)**
## IRC ## 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. :) 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 ## General
@ -17,6 +20,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(). - 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. - 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. - Optimize info caching, only check for cache files in scripts that use caching.
- Cleanup `main()`.
## Info ## Info
@ -29,11 +33,17 @@ Neofetch now has an irc channel at `#neofetch` on Freenode. If you have any ques
**Song**<br \> **Song**<br \>
- Simplify state detection. - Simplify state detection.
- [cmus] Simplify block and fix `artistsort` bug
**Battery**<br \>
- [MacOS] Fixed issue where battery always appears as charging. **[@jorgegonzalez](https://github.com/jorgegonzalez)**
**Color Blocks**<br \> **Color Blocks**<br \>
- Use start++ instead of adding it manually after case. **[@konimex](https://github.com/konimex)** - Use start++ instead of adding it manually after case. **[@konimex](https://github.com/konimex)**
## Images ## Images
- [iTerm2] Fixed blank images. - [iTerm2] Fixed blank images.
@ -43,3 +53,8 @@ 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. - Fixed bug causing macOS ascii art to be used on other Operating Systems.
- Display warning about 'ascii' being the new default mode. - Display warning about 'ascii' being the new default mode.
## Screenshot
- Use arrays for `$scrot_program`

View file

@ -1137,11 +1137,9 @@ get_song() {
"cmus"*) "cmus"*)
IFS=$'\n' IFS=$'\n'
song=($(cmus-remote -Q | grep -F -e "tag artist" -e "tag title" -e "status" | sort)) cmus=($(cmus-remote -Q | grep -F -e "tag artist " -e "tag title" -e "status" | sort))
state="${song[0]/status }" song="${cmus[1]/tag artist } - ${cmus[2]/tag title }"
artist="${song[1]/tag artist }" state="${cmus[0]/status }"
title="${song[2]/tag title }"
song="${artist/tag title } - ${title/tag artist }"
;; ;;
"mocp"*) "mocp"*)
@ -1711,7 +1709,8 @@ get_battery() {
"Mac OS X") "Mac OS X")
battery="$(pmset -g batt | grep -o '[0-9]*%')" 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}')"
[[ "$state" == "charging;" ]] && battery_state="charging"
;; ;;
"Windows") "Windows")
@ -1936,6 +1935,10 @@ get_image_backend() {
"ascii") get_ascii 2>/dev/null ;; "ascii") get_ascii 2>/dev/null ;;
esac esac
# Set cursor position next to ascii art.
[[ "$image_backend" != "off" ]] && \
printf "%b" "\033[$((${lines:-0} - ${prompt_loc:-0}))A\033[9999999D"
} }
get_ascii() { get_ascii() {
@ -2385,22 +2388,22 @@ scrot_program() {
# falling back to OS specific screenshot tools. # falling back to OS specific screenshot tools.
if [[ -n "$DISPLAY" ]]; then if [[ -n "$DISPLAY" ]]; then
if [[ "$scrot_cmd" != "auto" ]] && type -p "$scrot_cmd" >/dev/null; 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 elif type -p scrot >/dev/null; then
scrot_program="scrot" scrot_program=(scrot)
elif type -p maim >/dev/null; then elif type -p maim >/dev/null; then
scrot_program="maim" scrot_program=(maim)
elif type -p import >/dev/null; then 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 elif type -p imlib2_grab >/dev/null; then
scrot_program="imlib2_grab" scrot_program=(imlib2_grab)
elif type -p gnome-screenshot >/dev/null; then elif type -p gnome-screenshot >/dev/null; then
scrot_program="gnome-screenshot -f" scrot_program=(gnome-screenshot -f)
else else
err "Scrot: No screen capture tool found." err "Scrot: No screen capture tool found."
@ -2408,15 +2411,15 @@ scrot_program() {
fi fi
else else
case "$os" in case "$os" in
"Mac OS X") scrot_program="screencapture -S" ;; "Mac OS X") scrot_program=(screencapture -S) ;;
"Haiku") scrot_program="screenshot -s" ;; "Haiku") scrot_program=(screenshot -s) ;;
esac esac
fi fi
# Take the scrot. # 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 # TEXT FORMATTING
@ -2946,12 +2949,15 @@ get_term_padding() {
} }
dynamic_prompt() { dynamic_prompt() {
if [[ "$image_backend" == "image" ]]; then case "$image_backend" in
get_term_padding 2>/dev/null "image")
get_term_padding 2>/dev/null
# Calculate image height in terminal cells. # Calculate image height in terminal cells.
lines="$(((height + (${border:-0} * 2) + ${yoffset:-0}) / font_height))" lines="$(((height + (${border:-0} * 2) + ${yoffset:-0}) / font_height))"
fi ;;
"off") return ;;
esac
# If the info is higher than the ascii/image place the prompt # If the info is higher than the ascii/image place the prompt
# based on the info height instead of the ascii/image height. # based on the info height instead of the ascii/image height.
@ -3329,42 +3335,23 @@ main() {
get_bold get_bold
get_distro_colors 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. # 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 # Hide the cursor and disable line wrap
printf "\033[?25l\033[?7l" printf "\033[?25l\033[?7l"
get_image_backend 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 old_functions
get_cache_dir get_cache_dir
print_info 2>/dev/null print_info 2>/dev/null
dynamic_prompt
# Prompt calculation # w3m-img: Draw the image a second time to fix
if [[ "$image_backend" != "off" ]]; then # rendering issues in specific terminal emulators.
dynamic_prompt [[ "$image_backend" == "image" && "$image_program" == "w3m" ]] && display_image
# 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"
# Take a screenshot
[[ "$scrot" == "on" ]] && take_scrot [[ "$scrot" == "on" ]] && take_scrot
# Show error messages # Show error messages