Merge branch 'master' into img

This commit is contained in:
Dylan Araps 2016-10-22 00:03:05 +11:00
commit 5270e97943
5 changed files with 81 additions and 71 deletions

View file

@ -11,6 +11,7 @@
- Added new function called `checkoldflags` which informs users about deprecated config options. - Added new function called `checkoldflags` which informs users about deprecated config options.
- Change all `OS X` references to `macOS`. **[@iandrewt](https://github.com/iandrewt)** - Change all `OS X` references to `macOS`. **[@iandrewt](https://github.com/iandrewt)**
- Fix corrupted text when long lines are cut-off. - Fix corrupted text when long lines are cut-off.
- Don't dynamically place prompt in `image=off` mode.
## Operating System ## Operating System
@ -67,8 +68,15 @@ https://github.com/dylanaraps/neofetch/commit/3e9c3d648cb4c6f0d5fe5f0b96f9e29429
**CPU**<br \> **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)** - [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.
**Resolution**<br \> **Resolution**<br \>
- [macOS] Add @2x label for retina resolutions. **[@iandrewt](https://github.com/iandrewt)** - [macOS] Add @2x label for retina resolutions. **[@iandrewt](https://github.com/iandrewt)**
@ -96,6 +104,7 @@ https://github.com/dylanaraps/neofetch/commit/3e9c3d648cb4c6f0d5fe5f0b96f9e29429
**Terminal and Terminal Font**<br \> **Terminal and Terminal Font**<br \>
- Uppercase first letter of `term` and `termfont` outputs. - Uppercase first letter of `term` and `termfont` outputs.
- Don't print broken output of busybox's `ps`.
- Remove path from output. - Remove path from output.
**Song**<br \> **Song**<br \>

View file

@ -371,7 +371,9 @@ alias neofetch2="neofetch \
NOTE: This only support Linux with cpufreq. NOTE: This only support Linux with cpufreq.
--cpu_shorthand type Shorten the output of CPU --cpu_shorthand type Shorten the output of CPU
Possible values: name, speed, tiny, on, off 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) --distro_shorthand on/off Shorten the output of distro (tiny, on, off)
NOTE: This is only possible on Linux, macOS, and Solaris NOTE: This is only possible on Linux, macOS, and Solaris
--kernel_shorthand on/off Shorten the output of kernel --kernel_shorthand on/off Shorten the output of kernel

View file

@ -108,8 +108,11 @@ cpu_display="off"
# CPU Cores # CPU Cores
# Display CPU cores in output # Display CPU cores in output
# --cpu_cores on/off # Logical: All virtual cores
cpu_cores="on" # Physical: All physical cores
# --cpu_cores logical, physical, off
# Note: 'physical' doesn't work on BSD.
cpu_cores="logical"
# GPU # GPU

115
neofetch
View file

@ -268,73 +268,52 @@ getkernel() {
# Uptime {{{ # Uptime {{{
getuptime() { getuptime() {
# Get uptime in seconds
case "$os" in case "$os" in
"Linux" | "Windows") "Linux" | "Windows")
case "$distro" in seconds="$(< /proc/uptime)"
*"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "OpenWRT"* | "Windows"*) seconds="${seconds/.*}"
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}')"
;;
*)
uptime="$(uptime -p)"
[ "$uptime" == "up " ] && uptime="up $(awk -F'.' '{print $1}' /proc/uptime) seconds"
;;
esac
;; ;;
"Mac OS X" | "iPhone OS" | "BSD") "Mac OS X" | "iPhone OS" | "BSD")
# Get boot time in seconds
boot="$(sysctl -n kern.boottime)" boot="$(sysctl -n kern.boottime)"
boot="${boot/'{ sec = '}" boot="${boot/'{ sec = '}"
boot="${boot/,*}" boot="${boot/,*}"
# Get current date in seconds # Get current date in seconds
now="$(date +%s)" now="$(date +%s)"
uptime="$((now - boot))" seconds="$((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"
;; ;;
"Solaris") "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 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. # Make the output of uptime smaller.
case "$uptime_shorthand" in case "$uptime_shorthand" in
"on") "on")
@ -353,7 +332,7 @@ getuptime() {
uptime="${uptime/ minutes/m}" uptime="${uptime/ minutes/m}"
uptime="${uptime/ minute/m}" uptime="${uptime/ minute/m}"
uptime="${uptime/ seconds/s}" uptime="${uptime/ seconds/s}"
uptime="${uptime/,}" uptime="${uptime//,}"
;; ;;
esac esac
} }
@ -724,7 +703,11 @@ getcpu() {
speed="$((speed / 100))" speed="$((speed / 100))"
fi 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 # Fix for speeds under 1ghz
if [ -z "${speed:1}" ]; then if [ -z "${speed:1}" ]; then
@ -738,7 +721,12 @@ getcpu() {
"Mac OS X") "Mac OS X")
cpu="$(sysctl -n machdep.cpu.brand_string)" 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") "iPhone OS")
@ -884,8 +872,11 @@ getcpu() {
speed="$(psrinfo -v | awk '/operates at/ {print $6}')" speed="$(psrinfo -v | awk '/operates at/ {print $6}')"
speed="$((speed / 100))" speed="$((speed / 100))"
# Get cpu cores # Show/hide hyperthreaded cores
cores="$(kstat -m cpu_info | grep -c "chip_id")" 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 # Fix for speeds under 1ghz
if [ -z "${speed:1}" ]; then if [ -z "${speed:1}" ]; then
@ -913,7 +904,7 @@ getcpu() {
cpu="${cpu//with Radeon HD Graphics}" cpu="${cpu//with Radeon HD Graphics}"
# Add cpu cores to output # Add cpu cores to output
[ "$cpu_cores" == "on" ] && [ "$cores" ] && \ [ "$cpu_cores" != "off" ] && [ "$cores" ] && \
cpu="${cpu/@/(${cores}) @}" cpu="${cpu/@/(${cores}) @}"
# Make the output of cpu shorter # Make the output of cpu shorter
@ -1581,7 +1572,7 @@ getterm() {
case "${name// }" in case "${name// }" in
"${SHELL/*\/}" | *"sh" | "tmux"* | "screen") getterm "$parent" ;; "${SHELL/*\/}" | *"sh" | "tmux"* | "screen") getterm "$parent" ;;
"login"* | *"Login"* | "init") term="$(tty)" ;; "login"* | *"Login"* | "init") term="$(tty)" ;;
"ruby" | "1" | "systemd" | "sshd"* | "python"*) unset term ;; "ruby" | "1" | "systemd" | "sshd"* | "python"* | "USER"*"PID"*) unset term ;;
"gnome-terminal-") term="gnome-terminal" ;; "gnome-terminal-") term="gnome-terminal" ;;
*) term="${name##*/}" ;; *) term="${name##*/}" ;;
esac esac
@ -2916,7 +2907,7 @@ kdeconfigdir() {
dynamicprompt() { dynamicprompt() {
# Calculate image height in terminal cells. # Calculate image height in terminal cells.
# The '+ 4' adds a gap between the prompt and the content. # The '+ 4' adds a gap between the prompt and the content.
[ "$image" != "ascii" ] && [ "$image" != "off" ] && \ [ "$image" != "ascii" ] && \
lines="$((${height:-1} / ${font_height:-1} + 4))" lines="$((${height:-1} / ${font_height:-1} + 4))"
# If the info is higher than the ascii/image place the prompt # If the info is higher than the ascii/image place the prompt
@ -2975,7 +2966,9 @@ usage() { cat << EOF
NOTE: This only support Linux with cpufreq. NOTE: This only support Linux with cpufreq.
--cpu_shorthand type Shorten the output of CPU --cpu_shorthand type Shorten the output of CPU
Possible values: name, speed, tiny, on, off 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) --distro_shorthand on/off Shorten the output of distro (tiny, on, off)
NOTE: This is only possible on Linux, macOS, and Solaris NOTE: This is only possible on Linux, macOS, and Solaris
--kernel_shorthand on/off Shorten the output of kernel --kernel_shorthand on/off Shorten the output of kernel
@ -3312,17 +3305,17 @@ main() {
# Display the image if enabled # Display the image if enabled
displayimage displayimage
fi
# Set cursor position next to ascii art # Set cursor position next to ascii art
printf "\033[$((${lines:-4} - ${prompt_loc:-4}))A" printf "\033[$((${lines:-4} - ${prompt_loc:-4}))A"
# Reset horizontal cursor position # Reset horizontal cursor position
printf "\033[9999999D" printf "\033[9999999D"
fi
# Print the info # Print the info
printinfo printinfo
dynamicprompt [ "$image" != "off" ] && dynamicprompt
# Re-enable line wrap # Re-enable line wrap
printf "%b%s" "\033[?7h" printf "%b%s" "\033[?7h"

View file

@ -35,8 +35,10 @@ Shorten the output of CPU
.br .br
Possible values: name, speed, tiny, on, off Possible values: name, speed, tiny, on, off
.TP .TP
.B \--cpu_cores 'on/off' .B \--cpu_cores 'logical/physical/off'
Whether or not to display the number of CPU cores Whether or not to display the number of CPU cores
.br
Note: 'physical' doesn't work on BSD.
.TP .TP
.B \--distro_shorthand 'on/off' .B \--distro_shorthand 'on/off'
Shorten the output of distro (tiny, on, off) Shorten the output of distro (tiny, on, off)
@ -51,7 +53,8 @@ Shorten the output of uptime (tiny, on, off)
.TP .TP
.B \--refresh_rate 'on/off' .B \--refresh_rate 'on/off'
Whether to display the refresh rate of each monitor Whether to display the refresh rate of each monitor
Unsupported on Windows .br
Note: Unsupported on Windows
.TP .TP
.B \--gpu_shorthand 'on/off' .B \--gpu_shorthand 'on/off'
Shorten the output of GPU (tiny, on, off) Shorten the output of GPU (tiny, on, off)