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

This commit is contained in:
Muhammad Herdiansyah 2017-06-10 13:07:44 +07:00
commit 69b642b759
9 changed files with 273 additions and 85 deletions

218
neofetch
View file

@ -92,7 +92,10 @@ get_distro() {
distro="$(lsb_release $lsb_flags)"
elif type -p guix >/dev/null; then
distro="GuixSD"
case "$distro_shorthand" in
"on" | "tiny") distro="GuixSD" ;;
*) distro="GuixSD $(guix system -V | awk 'NR==1{printf $5}')"
esac
elif type -p crux >/dev/null; then
distro="$(crux)"
@ -104,6 +107,9 @@ get_distro() {
elif type -p tazpkg >/dev/null; then
distro="SliTaz $(< /etc/slitaz-release)"
elif type -p kpm > /dev/null; then
distro="KSLinux"
elif [[ -d "/system/app/" && -d "/system/priv-app" ]]; then
distro="Android $(getprop ro.build.version.release)"
@ -215,8 +221,14 @@ get_distro() {
[[ -z "$distro" ]] && distro="$os (Unknown)"
# Get OS architecture.
[[ "$os_arch" == "on" ]] && \
if [[ "$os_arch" == "on" ]]; then
case "$os" in
"Solaris" | "AIX" | "BSD" | "Haiku") machine_arch="$(uname -p)" ;;
*) machine_arch="$(uname -m)" ;;
esac
distro+=" ${machine_arch}"
fi
[[ "${ascii_distro:-auto}" == "auto" ]] && \
ascii_distro="$(trim "$distro")"
@ -241,7 +253,14 @@ get_model() {
fi
;;
"Mac OS X") model="$(sysctl -n hw.model)" ;;
"Mac OS X")
if [[ "$(kextstat | grep "FakeSMC")" != "" ]]; then
model="Hackintosh (SMBIOS: $(sysctl -n hw.model))"
else
model="$(sysctl -n hw.model)"
fi
;;
"iPhone OS")
case "$machine_arch" in
"iPad1,1") model="iPad" ;;
@ -262,7 +281,7 @@ get_model() {
"iPhone2,1") model="iPhone 3GS" ;;
"iPhone3,"[1-3]) model="iPhone 4" ;;
"iPhone4,1") model="iPhone 4S" ;;
"iPhone5,"[1-2]) model="iPhone 4" ;;
"iPhone5,"[1-2]) model="iPhone 5" ;;
"iPhone5,"[3-4]) model="iPhone 5c" ;;
"iPhone6,"[1-2]) model="iPhone 5s" ;;
"iPhone7,2") model="iPhone 6" ;;
@ -440,6 +459,9 @@ get_packages() {
type -p dpkg >/dev/null && \
packages="$((packages+=$(dpkg --get-selections | grep -cv deinstall$)))"
type -p kpm >/dev/null && \
packages="$((packages+=$(kpm --get-selections | grep -cv deinstall$)))"
type -p pkgtool >/dev/null && \
packages="$((packages+=$(ls -1 /var/log/packages | wc -l)))"
@ -942,6 +964,7 @@ get_cpu() {
cpu="${cpu//*$'\n'}"
cpu="${cpu/[0-9]\.*}"
cpu="${cpu/ @*}"
cpu="${cpu/\(portid*}"
# Get CPU speed.
speed="$(psrinfo -v | awk '/operates at/ {print $6; exit}')"
@ -1194,7 +1217,16 @@ get_gpu() {
esac
;;
"BSD" | "Solaris" | "MINIX" | "AIX")
"Windows")
gpu="$(wmic path Win32_VideoController get caption)"
gpu="${gpu//Caption}"
;;
"Haiku")
gpu="$(listdev | grep -A2 -F 'device Display controller' | awk -F':' '/device beef/ {print $2}')"
;;
*)
case "$kernel_name" in
"FreeBSD"* | "DragonFly"*)
gpu="$(pciconf -lv | grep -B 4 -F "VGA" | grep -F "device")"
@ -1208,15 +1240,6 @@ get_gpu() {
;;
esac
;;
"Windows")
gpu="$(wmic path Win32_VideoController get caption)"
gpu="${gpu//Caption}"
;;
"Haiku")
gpu="$(listdev | grep -A2 -F 'device Display controller' | awk -F':' '/device beef/ {print $2}')"
;;
esac
if [[ "$gpu_brand" == "off" ]]; then
@ -1262,8 +1285,11 @@ get_memory() {
case "$kernel_name" in
"NetBSD"*) mem_free="$(($(awk -F ':|kB' '/MemFree:/ {printf $2}' /proc/meminfo) / 1024))" ;;
"FreeBSD"* | "DragonFly"*)
mem_free="$(top -d 1 | awk -F ',' '/^Mem:/ {print $5}')"
mem_free="${mem_free/M Free}"
hw_pagesize="$(sysctl -n hw.pagesize)"
mem_inactive="$(($(sysctl -n vm.stats.vm.v_inactive_count) * hw_pagesize))"
mem_unused="$(($(sysctl -n vm.stats.vm.v_free_count) * hw_pagesize))"
mem_cache="$(($(sysctl -n vm.stats.vm.v_cache_count) * hw_pagesize))"
mem_free="$(((mem_inactive + mem_unused + mem_cache) / 1024 / 1024))"
;;
"MINIX")
mem_free="$(top -d 1 | awk -F ',' '/^Memory:/ {print $2}')"
@ -1422,19 +1448,6 @@ get_song() {
get_resolution() {
case "$os" in
"Linux" | "BSD" | "Solaris" | "MINIX" | "AIX")
if type -p xrandr >/dev/null; then
case "$refresh_rate" in
"on") resolution="$(xrandr --nograb --current | awk 'match($0,/[0-9]*\.[0-9]*\*/) {printf $1 " @ " substr($0,RSTART,RLENGTH) "Hz, "}')" ;;
"off") resolution="$(xrandr --nograb --current | awk '/\*/ {printf $1 ", "}')" ;;
esac
resolution="${resolution//\*}"
elif type -p xdpyinfo >/dev/null; then
resolution="$(xdpyinfo | awk '/dimensions:/ {printf $2}')"
fi
;;
"Mac OS X")
if type -p screenresolution >/dev/null; then
resolution="$(screenresolution get 2>&1 | awk '/Display/ {printf $6 "Hz, "}')"
@ -1479,6 +1492,19 @@ get_resolution() {
[[ "$refresh_rate" == "off" ]] && resolution="${resolution/ @*}"
;;
*)
if type -p xrandr >/dev/null; then
case "$refresh_rate" in
"on") resolution="$(xrandr --nograb --current | awk 'match($0,/[0-9]*\.[0-9]*\*/) {printf $1 " @ " substr($0,RSTART,RLENGTH) "Hz, "}')" ;;
"off") resolution="$(xrandr --nograb --current | awk '/\*/ {printf $1 ", "}')" ;;
esac
resolution="${resolution//\*}"
elif type -p xdpyinfo >/dev/null; then
resolution="$(xdpyinfo | awk '/dimensions:/ {printf $2}')"
fi
;;
esac
resolution="${resolution%,*}"
@ -1660,16 +1686,20 @@ get_term() {
# Check $PPID for terminal emulator.
while [[ -z "$term" ]]; do
parent="$(get_ppid "$parent")"
name="$(get_process_name "$parent")"
case "${name// }" in
"${SHELL/*\/}" | *"sh" | "tmux"* | "screen" | "su"*) ;;
"login"* | *"Login"* | "init" | "(init)") term="$(tty)" ;;
"ruby" | "1" | "systemd" | "sshd"* | "python"* | "USER"*"PID"*) break ;;
"gnome-terminal-") term="gnome-terminal" ;;
*) term="${name##*/}" ;;
esac
if [[ "$SSH_CONNECTION" ]]; then
term="$SSH_TTY"
else
parent="$(get_ppid "$parent")"
[[ -z "$parent" ]] && break
name="$(get_process_name "$parent")"
case "${name// }" in
"${SHELL/*\/}" | *"sh" | "tmux"* | "screen" | "su"*) ;;
"login"* | *"Login"* | "init" | "(init)") term="$(tty)" ;;
"ruby" | "1" | "systemd" | "sshd"* | "python"* | "USER"*"PID"*) break ;;
"gnome-terminal-") term="gnome-terminal" ;;
*) term="${name##*/}" ;;
esac
fi
done
# Log that the function was run.
@ -1762,6 +1792,34 @@ get_term_font() {
[[ "$profile_filename" ]] && term_font="$(awk -F '=|,' '/Font=/ {print $2 " " $3}' "$profile_filename")"
;;
"mate-terminal")
# To get the actual config we have to create a temporarily file with the --save-config option.
mateterm_config="/tmp/mateterm.cfg"
# Ensure /tmp exists and we do not overwrite anything.
if [[ -d /tmp && ! -f "$mateterm_config" ]]; then
mate-terminal --save-config="$mateterm_config"
role="$(xprop -id "${WINDOWID}" WM_WINDOW_ROLE)"
role="${role##*= }"
term_id="$(grep -A1 "${role//\"}" "$mateterm_config")"
term_id="${term_id##*=}"
profile="$(grep -A1 "\[$term_id\]" "$mateterm_config")"
profile="${profile##*=}"
rm -f "$mateterm_config"
if [[ "$(gsettings get org.mate.terminal.profile:/org/mate/terminal/profiles/"${profile}"/ use-system-font)" == "true" ]]; then
term_font="$(gsettings get org.mate.interface monospace-font-name)"
else
term_font="$(gsettings get org.mate.terminal.profile:/org/mate/terminal/profiles/"${profile}"/ font)"
fi
term_font="$(trim_quotes "$term_font")"
fi
;;
"mintty")
term_font="$(awk -F '=' '!/^($|#)/ && /Font/ {printf $2; exit}' "${HOME}/.minttyrc")"
;;
@ -2224,7 +2282,29 @@ get_image_source() {
get_wallpaper() {
case "$os" in
"Linux" | "BSD" | "Solaris" | "MINIX" | "AIX")
"Mac OS X")
image="$(osascript -e 'tell application "System Events" to picture of current desktop')"
;;
"Windows")
case "$distro" in
"Windows XP")
case "$kernel_name" in
"CYGWIN"*) image="/cygdrive/c/Documents and Settings/${USER}" ;;
"MSYS2"* | "MINGW*") image="/c/Documents and Settings/${USER}" ;;
esac
image+="/Local Settings/Application Data/Microsoft"
image+="/Wallpaper1.bmp"
;;
"Windows"*)
image="$APPDATA/Microsoft/Windows/Themes"
image+="/TranscodedWallpaper.jpg"
;;
esac
;;
*)
# Get DE if user has disabled the function.
((de_run != 1)) && get_de
@ -2255,28 +2335,6 @@ get_wallpaper() {
image="${image/'file://'}"
image="$(trim_quotes "$image")"
;;
"Mac OS X")
image="$(osascript -e 'tell application "System Events" to picture of current desktop')"
;;
"Windows")
case "$distro" in
"Windows XP")
case "$kernel_name" in
"CYGWIN"*) image="/cygdrive/c/Documents and Settings/${USER}" ;;
"MSYS2"* | "MINGW*") image="/c/Documents and Settings/${USER}" ;;
esac
image+="/Local Settings/Application Data/Microsoft"
image+="/Wallpaper1.bmp"
;;
"Windows"*)
image="$APPDATA/Microsoft/Windows/Themes"
image+="/TranscodedWallpaper.jpg"
;;
esac
;;
esac
# If image is an xml file, don't use it.
@ -2297,6 +2355,9 @@ get_w3m_img_path() {
elif [[ -x "/usr/libexec64/w3m/w3mimgdisplay" ]]; then
w3m_img_path="/usr/libexec64/w3m/w3mimgdisplay"
elif [[ -x "/usr/local/libexec/w3m/w3mimgdisplay" ]]; then
w3m_img_path="/usr/local/libexec/w3m/w3mimgdisplay"
else
err "Image: w3m-img wasn't found on your system"
fi
@ -2534,7 +2595,7 @@ display_image() {
printf "%b\n" "0;1;$xoffset;$yoffset;$width;$height;;;;;$image\n4;\n3;" |\
"${w3m_img_path:-false}" -bg "$background_color" >/dev/null & 2>&1 || to_off "Image: w3m-img failed to display the image."
zws=" "
zws="\xE2\x80\x8B\x20"
;;
esac
}
@ -2741,11 +2802,11 @@ get_underline() {
get_line_break() {
# Print it directly.
printf "%s\n" "${zws}"
printf "%b\n" "${zws}"
# Calculate info height.
((++info_height))
line_breaks+=$'\n'
line_breaks+="\n"
# Tell info() that we printed manually.
prin=1
@ -2868,6 +2929,11 @@ get_distro_colors() {
ascii_file="archlabs"
;;
*"XFerience"*)
set_colors 6 6 7 1
ascii_file="arch_xferience"
;;
"Arch"*)
set_colors 6 6 7 1
ascii_file="arch"
@ -3063,6 +3129,11 @@ get_distro_colors() {
ascii_file="korora"
;;
"KSLinux"*)
set_colors 4 7 1
ascii_file="kslinux"
;;
"Kubuntu"*)
set_colors 4 7 1
ascii_file="kubuntu"
@ -3098,6 +3169,11 @@ get_distro_colors() {
ascii_file="manjaro"
;;
"Maui"*)
set_colors 6 7
ascii_file="maui"
;;
"Mer"*)
set_colors 4 7 1
ascii_file="mer"
@ -3333,6 +3409,11 @@ get_distro_colors() {
ascii_file="ubuntu-gnome"
;;
"Ubuntu-MATE"*)
set_colors 2 7
ascii_file="ubuntu-mate"
;;
"ubuntu_old")
set_colors 1 7 3
ascii_file="ubuntu_old"
@ -3358,7 +3439,7 @@ get_distro_colors() {
ascii_file="void"
;;
*"[Windows 10]"* | *"on Windows 10"* | "Windows 8"* | "Windows 10"*)
*"[Windows 10]"* | *"on Windows 10"* | "Windows 8"* | "Windows 10"* | "windows10" | "windows8" )
set_colors 6 7
ascii_file="windows10"
;;
@ -3554,7 +3635,7 @@ get_user_config() {
config_file="${XDG_CONFIG_HOME}/neofetch/config"
elif [[ -f "/etc/neofetch/config" ]]; then
cp "/usr/share/neofetch/config" "${XDG_CONFIG_HOME}/neofetch"
cp "/etc/neofetch/config" "${XDG_CONFIG_HOME}/neofetch"
config_file="${XDG_CONFIG_HOME}/neofetch/config"
elif [[ -f "/usr/local/etc/neofetch/config" ]]; then
@ -3734,11 +3815,10 @@ old_options() {
cache_uname() {
# Cache the output of uname so we don't
# have to spawn it multiple times.
uname=($(uname -srm))
uname=($(uname -sr))
kernel_name="${uname[0]}"
kernel_version="${uname[1]}"
machine_arch="${uname[2]}"
}
convert_time() {