Merge pull request #320 from dylanaraps/openwrt-fixes

Openwrt fixes
This commit is contained in:
Dylan Araps 2016-08-26 13:26:08 +10:00 committed by GitHub
commit 68624f8165
3 changed files with 63 additions and 37 deletions

16
1.8.md
View file

@ -38,6 +38,7 @@ bottom of the window. See [#279](https://github.com/dylanaraps/neofetch/pull/279
- `-v` now shows where the config files were sourced from. - `-v` now shows where the config files were sourced from.
- Removed in-script config in favor of sourcing the default user config. - Removed in-script config in favor of sourcing the default user config.
- Moved commands near the bottom of the script to a new function called `main`. - Moved commands near the bottom of the script to a new function called `main`.
- Use `read -s` instead of `stty -echo` and `stty +echo`.
- Cleanup - Cleanup
@ -75,6 +76,11 @@ bottom of the window. See [#279](https://github.com/dylanaraps/neofetch/pull/279
- Use faster `$(())` syntax for index variables. - Use faster `$(())` syntax for index variables.
**Title**<br \>
- Added additional fallback which gets the current username from `$HOME`.
**Color Blocks**<br \> **Color Blocks**<br \>
- Added `--block_height` / `$block_height` to change the number of lines high each<br \> - Added `--block_height` / `$block_height` to change the number of lines high each<br \>
@ -103,11 +109,14 @@ block will be.
- [Cmus] The function now works on both OS X and Linux. - [Cmus] The function now works on both OS X and Linux.
- [iTunes] Fix song not displaying. **[@iandrewt](https://github.com/iandrewt)** - [iTunes] Fix song not displaying. **[@iandrewt](https://github.com/iandrewt)**
**CPU**<br \>
- Simplify CPU Core command.
**CPU Usage**<br \> **CPU Usage**<br \>
- Fixed broken CPU usage output on BSD and Windows - Fixed broken CPU usage output on BSD and Windows.
- Fixed misleading output on Linux / Mac OS X - Fixed misleading output on Linux / Mac OS X.
- Moved CPU Usage to its own dedicated function - Moved CPU Usage to its own dedicated function.
### Image ### Image
@ -142,4 +151,5 @@ distro ascii files. See this wiki page that explains the syntax. [Link](https://
- Fix a color issue with Debian's ascii logo. - Fix a color issue with Debian's ascii logo.
- Added `--ascii_distro mac` as a shorter way of using the OS X ascii. - Added `--ascii_distro mac` as a shorter way of using the OS X ascii.
- Added missing `$ascii_distro` config option. - Added missing `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ZZZZZZ${c2}MMM${c1}Z${c2}M${c1}ZZZZZZZZZZ${c2}MMMM ${c1}.ZZZZZZZZZZZZZ${c2}MMM${c1}Z${c2}M${c1}ZZZZZZZZZZ${c2}MMMM
${c1} .ZZZZZZZZZZZ${c2}MMM${c1}7ZZ${c2}MM${c1}ZZZZZZZZZZ7${c2}M ${c1}.ZZZZZZZZZZZ${c2}MMM${c1}7ZZ${c2}MM${c1}ZZZZZZZZZZ7${c2}M
${c1} ZZZZZZZZZ${c2}MMMM${c1}ZZZZ${c2}MMMM${c1}ZZZZZZZ77 ${c1} ZZZZZZZZZ${c2}MMMM${c1}ZZZZ${c2}MMMM${c1}ZZZZZZZ77
${c2} MMMMMMMMMMMM${c1}ZZZZZ${c2}MMMM${c1}ZZZZZ77 ${c2} MMMMMMMMMMMM${c1}ZZZZZ${c2}MMMM${c1}ZZZZZ77
${c2} MMMMMMMMMM${c1}7ZZZZZZ${c2}MMMMM${c1}ZZ77 ${c2} MMMMMMMMMM${c1}7ZZZZZZ${c2}MMMMM${c1}ZZ77
${c2} .MMMMMMM${c1}ZZZZZZZZ${c2}MMMMM${c1}Z7Z ${c2} .MMMMMMM${c1}ZZZZZZZZ${c2}MMMMM${c1}Z7Z
${c2} MMMMM${c1}ZZZZZZZZZ${c2}MMMMMMM ${c2} MMMMM${c1}ZZZZZZZZZ${c2}MMMMMMM
${c1} NZZZZZZZZZZZ${c2}MMMMM ${c1} NZZZZZZZZZZZ${c2}MMMMM
${c1} ZZZZZZZZZ${c2}MM) ${c1} ZZZZZZZZZ${c2}MM)
" "

View file

@ -56,6 +56,7 @@ getdistro() {
# Workaround for distros that store the value differently. # Workaround for distros that store the value differently.
[ -z "$distro" ] && distro="$(awk -F 'TAILS_PRODUCT_NAME="|"' '/^TAILS_PRODUCT_NAME=/ {printf $2}' /etc/*ease)" [ -z "$distro" ] && distro="$(awk -F 'TAILS_PRODUCT_NAME="|"' '/^TAILS_PRODUCT_NAME=/ {printf $2}' /etc/*ease)"
[ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease)" [ -z "$distro" ] && distro="$(awk '/BLAG/ {print $1; exit}' /etc/*ease)"
[ -z "$distro" ] && distro="$(awk -F "'" '/^DISTRIB_DESCRIPTION/ {print $2}' /etc/openwrt_release)"
fi fi
;; ;;
@ -128,7 +129,7 @@ getdistro() {
# Title {{{ # Title {{{
gettitle() { gettitle() {
title="${USER:-$(whoami)}@${HOSTNAME:-$(hostname)}" title="${USER:-$(whoami || printf "%s" "${HOME/*\/}")}@${HOSTNAME:-$(hostname)}"
} }
# }}} # }}}
@ -150,7 +151,7 @@ getuptime() {
case "$os" in case "$os" in
"Linux" | "Windows") "Linux" | "Windows")
case "$distro" in case "$distro" in
*"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "Windows"*) *"Puppy"* | "Quirky Werewolf"* | "Alpine Linux"* | "OpenWRT"* | "Windows"*)
uptime="$(uptime | awk -F ':[0-9]{2}+ |(, ){1}+' '{printf $2}')" uptime="$(uptime | awk -F ':[0-9]{2}+ |(, ){1}+' '{printf $2}')"
;; ;;
@ -277,6 +278,9 @@ getpackages() {
type -p apk >/dev/null 2>&1 && \ type -p apk >/dev/null 2>&1 && \
packages="$((packages+=$(apk info | wc -l)))" packages="$((packages+=$(apk info | wc -l)))"
type -p opkg >/dev/null 2>&1 && \
packages="$((packages+=$(opkg list-installed | wc -l)))"
type -p pacman-g2 >/dev/null 2>&1 && \ type -p pacman-g2 >/dev/null 2>&1 && \
packages="$((packages+=$(pacman-g2 -Q | wc -l)))" packages="$((packages+=$(pacman-g2 -Q | wc -l)))"
@ -572,7 +576,7 @@ getcpu() {
speed="$((speed / 100))" speed="$((speed / 100))"
fi fi
cores="$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo)" cores="$(grep -c ^processor /proc/cpuinfo)"
# Fix for speeds under 1ghz # Fix for speeds under 1ghz
if [ -z "${speed:1}" ]; then if [ -z "${speed:1}" ]; then
@ -1467,17 +1471,29 @@ gettermfont() {
getdisk() { getdisk() {
# df flags # df flags
case "$os" in case "$os" in
"Linux" | "iPhone OS" | "Windows" | "Solaris") df_flags="-h -l --total" ;; "Linux" | "iPhone OS" | "Windows" | "Solaris")
df_flags="-h -l --total"
df_dir="total"
case "$distro" in
"OpenWRT"*) df_flags="-h"; df_dir="rootfs" ;;
esac
;;
"Mac OS X" | "BSD") "Mac OS X" | "BSD")
case "$distro" in case "$distro" in
"FreeBSD"* | *"OS X"* ) df_flags="-H / -l" ;; "FreeBSD"* | *"OS X"* )
df_flags="-l -H /"
df_dir="/"
;;
*) return ;; *) return ;;
esac esac
;; ;;
esac esac
# Get the disk info # Get the disk info
disk="$(df $df_flags 2>/dev/null | awk 'END{print $2 ":" $3 ":" $5}')" disk="$(df $df_flags 2>/dev/null | awk -v dir="$df_dir" '$0 ~ dir {print $2 ":" $3 ":" $5}')"
# Format the output # Format the output
disk_used="${disk#*:}" disk_used="${disk#*:}"
@ -1868,14 +1884,16 @@ getascii() {
ascii_strip="${ascii_strip//'\\'/ }" ascii_strip="${ascii_strip//'\\'/ }"
ascii_strip="${ascii_strip//'\'}" ascii_strip="${ascii_strip//'\'}"
# Get ascii file size in rows/cols # Get lines/columns of the ascii file in pure bash.
ascii_size="$(awk 'END {printf NR " "}length>max{max=length}END{printf max}' <<< "$ascii_strip")" ascii_length=0
lines="${ascii_size/ *}" lines=1
ascii_length="${ascii_size/$lines}" while IFS='\n' read -r line 2>/dev/null; do
[ ${#line} -gt "$ascii_length" ] && ascii_length=${#line}
lines=$((lines+=1))
done <<< "$ascii_strip"
padding="\033[$((ascii_length + gap))C" padding="\033[$((ascii_length + gap))C"
printf "%b%s" "$print" printf "%b%s" "$print"
export LC_ALL=C export LC_ALL=C
} }
@ -1901,7 +1919,6 @@ getimage() {
esac esac
# Get terminal width and height # Get terminal width and height
stty -echo
if [ -n "$TMUX" ]; then if [ -n "$TMUX" ]; then
printf "%b%s" "\033Ptmux;\033\033[14t\033\033[c\033\\" printf "%b%s" "\033Ptmux;\033\033[14t\033\033[c\033\\"
read_flags="-d c" read_flags="-d c"
@ -1915,8 +1932,7 @@ getimage() {
fi fi
# The escape code above prints the output AFTER the prompt so this # The escape code above prints the output AFTER the prompt so this
read -t 1 ${read_flags} -s -r term_size builtin read -s -t 1 ${read_flags} -r term_size
stty echo
# Split the string # Split the string
if [ "$image_backend" == "tycat" ]; then if [ "$image_backend" == "tycat" ]; then
@ -2629,7 +2645,7 @@ kdeconfigdir() {
dynamicprompt() { dynamicprompt() {
# Get cursor position # Get cursor position
info_height="$(stty -echo; IFS=';' read -rdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}"; stty echo)" info_height="$(IFS=';' builtin read -srdR -t 1 -d c -p $'\033[6n\033[c' ROW COL; printf "%s" "${ROW#*[}")"
# Calculate image height in terminal cells. # Calculate image height in terminal cells.
# The '+ 3' adds a gap between the prompt and the content. # The '+ 3' adds a gap between the prompt and the content.