Merge master

This commit is contained in:
Dylan Araps 2016-10-22 01:39:31 +11:00
commit bb01418dca
5 changed files with 209 additions and 130 deletions

View file

@ -11,6 +11,7 @@
- Added new function called `checkoldflags` which informs users about deprecated config options.
- Change all `OS X` references to `macOS`. **[@iandrewt](https://github.com/iandrewt)**
- Fix corrupted text when long lines are cut-off.
- Don't dynamically place prompt in `image=off` mode.
## Operating System
@ -41,6 +42,24 @@ The final fix was as simple as adding a zero-width space before the info, here's
https://github.com/dylanaraps/neofetch/commit/3e9c3d648cb4c6f0d5fe5f0b96f9e29429af39d9
**Removed hard dependency on `\033[14t`**
Neofetch no longer requires a terminal emulator that supports `\033[14t` this means that neofetch now works in Konsole. Instead of using the escape sequence users now have three options for getting the terminal size in pixels.
- `xdotool`
- `xwininfo` + `xprop`
- `xwininfo` + `xdpyinfo`
Neofetch will detect whatever combination you have insalled and use these programs.
Note: `\033[14t` is still supported, if images already work for you then you don't have to install anything else.
- [w3m-img] Draw the image twice to fix rendering issues in Konsole.
- [w3m-img] Fix cursor position when using `yoffset`.
- [w3m-img] Add `-bg` support with the new option `--bg_color`.
- `neofetch --bg_color blue` will make the background behind the image blue.
- Note: The background color is only visible behind transparent parts of the image.
## Ascii
@ -67,8 +86,16 @@ https://github.com/dylanaraps/neofetch/commit/3e9c3d648cb4c6f0d5fe5f0b96f9e29429
**CPU**<br \>
- Expanded `cpu_cores` option by adding two new values, `logical` and `physical`.
- `logical`: Show all virtual cores (hyperthreaded).
- `physical`: Only show physical cores.
- [macOS] Print physical cores instead of hyper-threaded cores. **[@iandrewt](https://github.com/iandrewt)**
**Uptime**<br \>
- Rewrote uptime function to use seconds since boot instead of the `uptime` command.
- Every OS/Distro now has the pretty `uptime -p` output!
**Resolution**<br \>
- [macOS] Add @2x label for retina resolutions. **[@iandrewt](https://github.com/iandrewt)**
@ -91,11 +118,11 @@ https://github.com/dylanaraps/neofetch/commit/3e9c3d648cb4c6f0d5fe5f0b96f9e29429
- Fixed `block_width` not working.
- Fixed `% s` appearing in color blocks when neofetch is run from `tty`
- Fixed `block_width` being off by one. A value of `2` made the blocks `3` wide instead of `2` wide.
- Show 16 colors by default instead of 8.
**Terminal and Terminal Font**<br \>
- Uppercase first letter of `term` and `termfont` outputs.
- Don't print broken output of busybox's `ps`.
- Remove path from output.
**Song**<br \>

View file

@ -86,6 +86,21 @@ Have a look at the wiki, I've updated/added some new pages!<br \>
- Alpine Linux: You also need `ncurses`.
##### Image mode
These dependencies are required for image mode to work.
- Displaying images: `w3m-img` \[1\] or `iTerm2` or `Terminology` \[2\]
- Thumbnail creation: `imagemagick`
- Window size: A terminal emulator that supports `\033[14t` \[3\] or `xdotool` or `xwininfo + xprop` or `xwininfo + xdpyinfo`
\[1\] `w3m-img` is sometimes bundled together with `w3m`.
\[2\] Image support is built into Terminology and iTerm2, and doesn't require w3m-img.
\[3\] See this wiki page to find out if your terminal emulator supports `\033[14t` or if you need an additonal dependency.
##### iOS
These dependencies can all be installed through Cydia.<br \>
@ -99,19 +114,18 @@ Note: The cydia package installs these dependencies for you.
- `Gawk`
- `grep`
### Optional dependencies:
- Desktop Environment and Window Manager: `xprop` \[1\]
- Displaying images: `w3m-img` \[2\] \[3\] or `iTerm2` or `Terminology` \[4\]
- Thumbnail creation: `imagemagick`
- Displaying song information from Google Play Music Desktop Player: [`gpmdp-remote`](https://github.com/iAndrewT/gpmdp-remote)
- Desktop Environment and Window Manager: `xprop` \[1\]
##### Linux / BSD / Solaris
- Wallpaper: `feh`, `nitrogen` or `gsettings`
- Current Song: `mpc`, `cmus`, `moc`, `spotify`, `gpmdc`
- Resolution: `xorg-xrandr` or `xorg-xdpyinfo` \[5\]
- Screenshot: `scrot` \[6\]
- Resolution: `xorg-xrandr` or `xorg-xdpyinfo` \[2\]
- Screenshot: `scrot` \[3\]
##### OSX
@ -128,17 +142,10 @@ Note: The cydia package installs these dependencies for you.
\[1\] See **[#79](https://github.com/dylanaraps/neofetch/issues/79)** about why this is now a required dependency.
\[2\] `w3m-img` is sometimes bundled together with `w3m`.
\[3\] Image support only works in certain terminal emulators. The script will fallback to ascii mode on<br \>
terminal emulators that don't support the xterm escape sequences we're using for image sizing.
\[4\] Image support is built into Terminology and iTerm2, and doesn't require w3m-img.
\[5\] Xrandr is prefered over xdpyinfo as Xrandr supports multi monitor and refresh rate display in the<br \>
\[2\] Xrandr is prefered over xdpyinfo as Xrandr supports multi monitor and refresh rate display in the<br \>
output.
\[6\] You can use the launch flag `--scrot_cmd` or change the config option `$scrot_cmd` to your screenshot<br \>
\[3\] You can use the launch flag `--scrot_cmd` or change the config option `$scrot_cmd` to your screenshot<br \>
program's cmd and neofetch will use it instead of scrot.
@ -364,7 +371,9 @@ alias neofetch2="neofetch \
NOTE: This only support Linux with cpufreq.
--cpu_shorthand type Shorten the output of CPU
Possible values: name, speed, tiny, on, off
--cpu_cores on/off Whether or not to display the number of CPU cores
--cpu_cores type Whether or not to display the number of CPU cores
Takes: logical, physical, off
Note: 'physical' doesn't work on BSD.
--distro_shorthand on/off Shorten the output of distro (tiny, on, off)
NOTE: This is only possible on Linux, macOS, and Solaris
--kernel_shorthand on/off Shorten the output of kernel
@ -431,6 +440,8 @@ alias neofetch2="neofetch \
window. This only works with w3m.
--yoffset px How close the image will be to the top edge of the
window. This only works with w3m.
--bg_color color Background color to display behind transparent image.
This only works with w3m.
--gap num Gap between image and text.
NOTE: --gap can take a negative value which will
move the text closer to the left side.

View file

@ -108,8 +108,11 @@ cpu_display="off"
# CPU Cores
# Display CPU cores in output
# --cpu_cores on/off
cpu_cores="on"
# Logical: All virtual cores
# Physical: All physical cores
# --cpu_cores logical, physical, off
# Note: 'physical' doesn't work on BSD.
cpu_cores="logical"
# GPU
@ -233,7 +236,7 @@ underline_char="-"
# Color block range
# --block_range start end
start=0
end=15
end=7
# Toggle color blocks
# --color_blocks on/off
@ -301,11 +304,12 @@ image="wall"
thumbnail_dir="$HOME/.cache/thumbnails/neofetch"
# W3m-img path
# Only works with the w3m backend.
# Some systems have this in another location
w3m_img_path="/usr/lib/w3m/w3mimgdisplay"
# Image position
# Only works with the w3m backend
# Only works with the w3m backend.
# --image_position left/right
image_position="left"
@ -329,11 +333,18 @@ image_size="auto"
gap=2
# Image offsets
# Only works with the w3m backend.
# --xoffset px
# --yoffset px
yoffset=0
xoffset=0
# Image background color
# Only works with the w3m backend.
# Unset by default.
# --bg_color 'color', blue
background_color=
# }}}

195
neofetch
View file

@ -274,80 +274,52 @@ getkernel() {
# Uptime {{{
getuptime() {
# Get uptime in seconds
case "$os" in
"Linux" | "Windows")
case "$distro" in
*"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "OpenWRT"* | "Windows"*)
uptime="$(uptime | awk -F ':[0-9]{2}+ |(, ){1}+' '{printf $2}')"
;;
"openSUSE"*)
uptime="$(uptime | awk -F ':[0-9]{2}+[a-z][a-z] |(, ){1}+' '{printf $2}')"
;;
"Android"*)
uptime=$(uptime | awk -F ' up' '{print $2}')
uptime="${uptime//[0-9] user*}"
uptime="${uptime//load average*}"
uptime="${uptime%,*} ${uptime##*,}"
;;
*)
uptime="$(uptime -p)"
[ "$uptime" == "up " ] && uptime="up $(awk -F'.' '{print $1}' /proc/uptime) seconds"
;;
esac
seconds="$(< /proc/uptime)"
seconds="${seconds/.*}"
;;
"Mac OS X" | "iPhone OS" | "BSD")
# Get boot time in seconds
boot="$(sysctl -n kern.boottime)"
boot="${boot/'{ sec = '}"
boot="${boot/,*}"
# Get current date in seconds
now="$(date +%s)"
uptime="$((now - boot))"
# Convert uptime to days/hours/mins
minutes="$((uptime / 60%60))"
hours="$((uptime / 3600%24))"
days="$((uptime / 86400))"
case "$minutes" in
1) minutes="1 minute" ;;
0) unset minutes ;;
*) minutes="$minutes minutes" ;;
esac
case "$hours" in
1) hours="1 hour" ;;
0) unset hours ;;
*) hours="$hours hours" ;;
esac
case "$days" in
1) days="1 day" ;;
0) unset days ;;
*) days="$days days" ;;
esac
[ "$hours" ] && \
[ "$minutes" ] && \
hours+=","
[ "$days" ] && \
[ "$hours" ] && \
days+=","
uptime="up $days $hours $minutes"
seconds="$((now - boot))"
;;
"Solaris")
uptime="$(uptime | /usr/xpg4/bin/awk -F ':[0-9]{2}+[a-z][a-z] |(, ){1}+' '{printf $2}')"
seconds="$(kstat -p unix:0:system_misc:snaptime | awk '{print $2}')"
seconds="${seconds/.*}"
;;
esac
days="$((seconds / 60 / 60 / 24)) days"
hours="$((seconds / 60 / 60 % 24)) hours"
minutes="$((seconds / 60 % 60)) minutes"
case "$days" in
"0 days") unset days ;;
"1 days") days="${days/s}" ;;
esac
case "$hours" in
"0 hours") unset hours ;;
"1 hours") hours="${hours/s}" ;;
esac
case "$minutes" in
"0 minutes") unset minutes ;;
"1 minutes") minutes="${minutes/s}" ;;
esac
uptime="${days:+$days, }${hours:+$hours, }${minutes}"
uptime="${uptime%', '}"
uptime="up ${uptime:-${seconds} seconds}"
# Make the output of uptime smaller.
case "$uptime_shorthand" in
"on")
@ -366,7 +338,7 @@ getuptime() {
uptime="${uptime/ minutes/m}"
uptime="${uptime/ minute/m}"
uptime="${uptime/ seconds/s}"
uptime="${uptime/,}"
uptime="${uptime//,}"
;;
esac
}
@ -742,7 +714,11 @@ getcpu() {
speed="$((speed / 100))"
fi
cores="$(grep -c ^processor /proc/cpuinfo)"
# Show/hide hyperthreaded cores
case "$cpu_cores" in
"logical" | "on") cores="$(grep -c ^processor /proc/cpuinfo)" ;;
"physical") cores="$(grep "^core id" /proc/cpuinfo | sort -u | wc -l)" ;;
esac
# Fix for speeds under 1ghz
if [ -z "${speed:1}" ]; then
@ -756,7 +732,12 @@ getcpu() {
"Mac OS X")
cpu="$(sysctl -n machdep.cpu.brand_string)"
cores="$(sysctl -n hw.ncpu)"
# Show/hide hyperthreaded cores
case "$cpu_cores" in
"logical" | "on") cores="$(sysctl -n hw.logicalcpu_max)" ;;
"physical") cores="$(sysctl -n hw.physicalcpu_max)" ;;
esac
;;
"iPhone OS")
@ -902,8 +883,11 @@ getcpu() {
speed="$(psrinfo -v | awk '/operates at/ {print $6}')"
speed="$((speed / 100))"
# Get cpu cores
cores="$(kstat -m cpu_info | grep -c "chip_id")"
# Show/hide hyperthreaded cores
case "$cpu_cores" in
"logical" | "on") cores="$(kstat -m cpu_info | grep -c "chip_id")" ;;
"physical") cores="$(psrinfo -p)" ;;
esac
# Fix for speeds under 1ghz
if [ -z "${speed:1}" ]; then
@ -931,7 +915,7 @@ getcpu() {
cpu="${cpu//with Radeon HD Graphics}"
# Add cpu cores to output
[ "$cpu_cores" == "on" ] && [ "$cores" ] && \
[ "$cpu_cores" != "off" ] && [ "$cores" ] && \
cpu="${cpu/@/(${cores}) @}"
# Make the output of cpu shorter
@ -2033,7 +2017,7 @@ getwallpaper() {
[ "${img/*\./}" == "xml" ] && img=""
# Error msg
[ -z "$img" ] && err "Wallpaper detection failed, falling back to ascii mode."
[ -z "$img" ] && err "Image: Wallpaper detection failed, falling back to ascii mode."
}
# }}}
@ -2044,7 +2028,7 @@ getascii() {
if [ ! -f "$ascii" ] || [ "$ascii" == "distro" ]; then
# Error message
[ "$ascii" != "distro" ] && \
[ ! -f "$ascii" ] && err "Ascii file not found, using distro ascii"
[ ! -f "$ascii" ] && err "Ascii: Ascii file not found, using distro ascii"
# Lowercase the distro name
if [ "$version" -le 3 ]; then
@ -2071,7 +2055,7 @@ getascii() {
if [ ! -f "$script_dir/ascii/distro/${ascii/ *}" ]; then
padding="\033[0C"
image="off"
err "Ascii file not found, falling back to text mode."
err "Ascii: Ascii file not found, falling back to text mode."
return
fi
@ -2128,6 +2112,30 @@ getimage() {
esac
# Get terminal width and height
if type -p xdotool >/dev/null 2>&1 && \
[ "$image_backend" != "iterm2" ]; then
current_window="$(xdotool getactivewindow)"
eval "$(xdotool getwindowgeometry --shell "$current_window")"
term_height="$HEIGHT"
term_width="$WIDTH"
elif type -p xwininfo >/dev/null 2>&1 && \
type -p xdpyinfo >/dev/null 2>&1 || \
type -p xprop >/dev/null 2>&1 && \
[ "$image_backend" != "iterm2" ]; then
if type -p xdpyinfo >/dev/null 2>&1; then
current_window="$(xdpyinfo | grep focus | grep -E -o 0x[0-9a-f]+)"
elif type -p xprop >/dev/null 2>&1; then
current_window="$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')"
fi
term_size="$(xwininfo -id "$current_window" | awk -F ': ' '/Width|Height/ {printf $2 " "}')"
term_width="${term_size/ *}"
term_height="${term_size/${term_width}}"
else
if [ -n "$TMUX" ]; then
printf "%b%s" "\033Ptmux;\033\033[14t\033\033[c\033\\"
read_flags="-d c"
@ -2158,15 +2166,18 @@ getimage() {
term_width="${term_size/*';'}"
fi
[ "${#term_size}" -le 5 ] && no_esc="1"
fi
# If $img isn't a file or the terminal doesn't support xterm escape sequences,
# fallback to ascii mode.
if [ ! -f "$img" ] || ([ "${#term_size}" -le 5 ] && [ "$image_backend" != "tycat" ]); then
if [ ! -f "$img" ] || ([ "$no_esc" == 1 ] && [ "$image_backend" != "tycat" ]); then
image="ascii"
getascii
# Error messages
[ ! -f "$img" ] && err "\$img, isn't a file, falling back to ascii mode."
[ "${#term_size}" -le 5 ] && err "Your terminal doesn't support \\\033[14t, falling back to ascii mode."
[ ! -f "$img" ] && err "Image: \$img, isn't a file, falling back to ascii mode."
[ "${#term_size}" -le 5 ] && err "Image: Your terminal doesn't support \\\033[14t, falling back to ascii mode."
return
else
@ -2308,7 +2319,7 @@ getw3m_img_path() {
else
image="ascii"
err "w3m-img wasn't found on your system, falling back to ascii mode."
err "Image: w3m-img wasn't found on your system, falling back to ascii mode."
fi
}
@ -2324,7 +2335,7 @@ displayimage() {
# appearing in specific terminal emulators.
sleep 0.05
printf "%b%s\n" "0;1;$xoffset;$yoffset;$width;$height;;;;;$img\n4;\n3;" |\
$w3m_img_path 2>/dev/null || padding="\033[0C"
$w3m_img_path -bg "$background_color" 2>/dev/null || padding="\033[0C"
;;
"iterm2")
@ -2778,8 +2789,10 @@ err() {
# Check for old flags {{{
checkoldflags() {
[ -n "$osx_buildversion" ] && err "\$osx_buildversion is deprecated, use \$distro_shorthand instead."
[ -n "$osx_codename" ] && err "\$osx_codename is deprecated, use \$distro_shorthand instead."
[ -n "$osx_buildversion" ] && err "Config: \$osx_buildversion is deprecated, use \$distro_shorthand instead."
[ -n "$osx_codename" ] && err "Config: \$osx_codename is deprecated, use \$distro_shorthand instead."
[ -n "$progress_char" ] && err "Config: \$progress_char is deprecated, use \$progress_char_elapsed and \$progress_char_total instead."
[ "$cpu_cores" == "on" ] && err "Config: \$cpu_cores='on' is deprecated, use \$cpu_cores='logical|physical|off' instead."
}
# }}}
@ -2821,9 +2834,9 @@ getdefaultconfig() {
fi
if source "$default_config"; then
err "Sourced default config ($default_config)"
err "Config: Sourced default config ($default_config)"
else
err "Default config not found, continuing..."
err "Config: Default config not found, continuing..."
fi
}
@ -2835,7 +2848,7 @@ getuserconfig() {
# Check $config_file
if [ -f "$config_file" ]; then
source "$config_file"
err "Sourced user config ($config_file)"
err "Config: Sourced user config ($config_file)"
return
fi
mkdir -p "$XDG_CONFIG_HOME/neofetch/"
@ -2861,7 +2874,7 @@ getuserconfig() {
fi
source "$config_file"
err "Sourced user config ($config_file)"
err "Config: Sourced user config ($config_file)"
}
# }}}
@ -2923,25 +2936,27 @@ kdeconfigdir() {
dynamicprompt() {
# Calculate image height in terminal cells.
# The '+ 4' adds a gap between the prompt and the content.
[ "$image" != "ascii" ] && \
lines="$((${height:-1} / ${font_height:-1} + 4))"
# The '+ 1' adds a gap between the prompt and the content.
if [ "$image" != "ascii" ]; then
lines="$((${height:-1} / ${font_height:-1} + 2))"
cursor_yoffset="$((${yoffset:-1} / ${font_height:-1}))"
fi
# If the info is higher than the ascii/image place the prompt
# based on the info height instead of the ascii/image height.
if [ "${lines:-0}" -lt "${info_height:-0}" ]; then
lines="0"
else
lines="$((lines - info_height - 4))"
lines="$((lines - info_height + cursor_yoffset))"
fi
# Set the prompt location
[ "$image" != "off" ] && printf "\033[${lines/-*/0}B"
# Add some padding if the lines are above 0
if [ "$lines" -gt 0 ]; then
# Add some padding
[ "$image_backend" != "w3m" ] && \
[ "$lines" -gt 0 ] && \
printf "\n\n"
fi
}
# }}}
@ -2983,7 +2998,9 @@ usage() { cat << EOF
NOTE: This only support Linux with cpufreq.
--cpu_shorthand type Shorten the output of CPU
Possible values: name, speed, tiny, on, off
--cpu_cores on/off Whether or not to display the number of CPU cores
--cpu_cores type Whether or not to display the number of CPU cores
Takes: logical, physical, off
Note: 'physical' doesn't work on BSD.
--distro_shorthand on/off Shorten the output of distro (tiny, on, off)
NOTE: This is only possible on Linux, macOS, and Solaris
--kernel_shorthand on/off Shorten the output of kernel
@ -3050,6 +3067,8 @@ usage() { cat << EOF
window. This only works with w3m.
--yoffset px How close the image will be to the top edge of the
window. This only works with w3m.
--bg_color color Background color to display behind transparent image.
This only works with w3m.
--gap num Gap between image and text.
NOTE: --gap can take a negative value which will
move the text closer to the left side.
@ -3189,6 +3208,7 @@ getargs() {
--crop_offset) crop_offset="$2" ;;
--xoffset) xoffset="$2" ;;
--yoffset) yoffset="$2" ;;
--background_color | --bg_color) background_color="$2" ;;
--gap) gap="$2" ;;
--clean)
rm -rf "$thumbnail_dir"
@ -3330,9 +3350,12 @@ main() {
# Print the info
printinfo
[ "$image" != "off" ] && dynamicprompt
# w3m-img: Draw the image a second time to fix
# rendering issues in specific terminal emulators.
[ "$image_backend" == "w3m" ] && displayimage
# Re-enable line wrap
printf "%b%s" "\033[?7h"

View file

@ -35,8 +35,10 @@ Shorten the output of CPU
.br
Possible values: name, speed, tiny, on, off
.TP
.B \--cpu_cores 'on/off'
.B \--cpu_cores 'logical/physical/off'
Whether or not to display the number of CPU cores
.br
Note: 'physical' doesn't work on BSD.
.TP
.B \--distro_shorthand 'on/off'
Shorten the output of distro (tiny, on, off)
@ -51,7 +53,8 @@ Shorten the output of uptime (tiny, on, off)
.TP
.B \--refresh_rate 'on/off'
Whether to display the refresh rate of each monitor
Unsupported on Windows
.br
Note: Unsupported on Windows
.TP
.B \--gpu_shorthand 'on/off'
Shorten the output of GPU (tiny, on, off)
@ -195,6 +198,10 @@ window in pixel. This only works with w3m.
How close the image will be to the top edge
of the window. This only works with w3m.
.TP
.B \--bg_color 'color'
Background color to display behind transparent image.
This only works with w3m.
.TP
.B \--gap 'num'
Gap between image and text.
.br