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.
- 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`.
- Use `read -s` instead of `stty -echo` and `stty +echo`.
- Cleanup
@ -75,6 +76,11 @@ bottom of the window. See [#279](https://github.com/dylanaraps/neofetch/pull/279
- Use faster `$(())` syntax for index variables.
**Title**<br \>
- Added additional fallback which gets the current username from `$HOME`.
**Color Blocks**<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.
- [iTunes] Fix song not displaying. **[@iandrewt](https://github.com/iandrewt)**
**CPU**<br \>
- Simplify CPU Core command.
**CPU Usage**<br \>
- Fixed broken CPU usage output on BSD and Windows
- Fixed misleading output on Linux / Mac OS X
- Moved CPU Usage to its own dedicated function
- Fixed broken CPU usage output on BSD and Windows.
- Fixed misleading output on Linux / Mac OS X.
- Moved CPU Usage to its own dedicated function.
### 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.
- Added `--ascii_distro mac` as a shorter way of using the OS X ascii.
- Added missing `$ascii_distro` config option.
- Use a pure bash solution to getting ascii size.

View File

@ -56,6 +56,7 @@ getdistro() {
# 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 '/BLAG/ {print $1; exit}' /etc/*ease)"
[ -z "$distro" ] && distro="$(awk -F "'" '/^DISTRIB_DESCRIPTION/ {print $2}' /etc/openwrt_release)"
fi
;;
@ -128,7 +129,7 @@ getdistro() {
# Title {{{
gettitle() {
title="${USER:-$(whoami)}@${HOSTNAME:-$(hostname)}"
title="${USER:-$(whoami || printf "%s" "${HOME/*\/}")}@${HOSTNAME:-$(hostname)}"
}
# }}}
@ -150,7 +151,7 @@ getuptime() {
case "$os" in
"Linux" | "Windows")
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}')"
;;
@ -277,6 +278,9 @@ getpackages() {
type -p apk >/dev/null 2>&1 && \
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 && \
packages="$((packages+=$(pacman-g2 -Q | wc -l)))"
@ -572,7 +576,7 @@ getcpu() {
speed="$((speed / 100))"
fi
cores="$(awk -F ': ' '/siblings/ {printf $2; exit}' /proc/cpuinfo)"
cores="$(grep -c ^processor /proc/cpuinfo)"
# Fix for speeds under 1ghz
if [ -z "${speed:1}" ]; then
@ -1467,17 +1471,29 @@ gettermfont() {
getdisk() {
# df flags
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")
case "$distro" in
"FreeBSD"* | *"OS X"* ) df_flags="-H / -l" ;;
"FreeBSD"* | *"OS X"* )
df_flags="-l -H /"
df_dir="/"
;;
*) return ;;
esac
;;
esac
# 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
disk_used="${disk#*:}"
@ -1868,14 +1884,16 @@ getascii() {
ascii_strip="${ascii_strip//'\\'/ }"
ascii_strip="${ascii_strip//'\'}"
# Get ascii file size in rows/cols
ascii_size="$(awk 'END {printf NR " "}length>max{max=length}END{printf max}' <<< "$ascii_strip")"
lines="${ascii_size/ *}"
ascii_length="${ascii_size/$lines}"
# Get lines/columns of the ascii file in pure bash.
ascii_length=0
lines=1
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"
printf "%b%s" "$print"
export LC_ALL=C
}
@ -1901,7 +1919,6 @@ getimage() {
esac
# Get terminal width and height
stty -echo
if [ -n "$TMUX" ]; then
printf "%b%s" "\033Ptmux;\033\033[14t\033\033[c\033\\"
read_flags="-d c"
@ -1915,8 +1932,7 @@ getimage() {
fi
# The escape code above prints the output AFTER the prompt so this
read -t 1 ${read_flags} -s -r term_size
stty echo
builtin read -s -t 1 ${read_flags} -r term_size
# Split the string
if [ "$image_backend" == "tycat" ]; then
@ -2629,7 +2645,7 @@ kdeconfigdir() {
dynamicprompt() {
# 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.
# The '+ 3' adds a gap between the prompt and the content.