Consistent function brackets

This commit is contained in:
Dylan Araps 2016-08-12 20:53:04 +10:00
parent 9ec7bbb421
commit bcec8c65da
1 changed files with 50 additions and 50 deletions

100
neofetch
View File

@ -38,7 +38,7 @@ esac
# Distro {{{ # Distro {{{
getdistro () { getdistro() {
[ "$distro" ] && return [ "$distro" ] && return
case "$os" in case "$os" in
@ -125,7 +125,7 @@ getdistro () {
# Title {{{ # Title {{{
gettitle () { gettitle() {
title="${USER:-$(whoami)}@${HOSTNAME:-$(hostname)}" title="${USER:-$(whoami)}@${HOSTNAME:-$(hostname)}"
} }
@ -144,7 +144,7 @@ getkernel() {
# Uptime {{{ # Uptime {{{
getuptime () { getuptime() {
case "$os" in case "$os" in
"Linux" | "Windows") "Linux" | "Windows")
case "$distro" in case "$distro" in
@ -239,7 +239,7 @@ getuptime () {
# Package Count {{{ # Package Count {{{
getpackages () { getpackages() {
case "$os" in case "$os" in
"Linux" | "iPhone OS") "Linux" | "iPhone OS")
type -p pacman >/dev/null 2>&1 && \ type -p pacman >/dev/null 2>&1 && \
@ -329,7 +329,7 @@ getpackages () {
# Shell {{{ # Shell {{{
getshell () { getshell() {
case "$shell_path" in case "$shell_path" in
"on") shell="$SHELL" ;; "on") shell="$SHELL" ;;
"off") shell="${SHELL##*/}" ;; "off") shell="${SHELL##*/}" ;;
@ -370,7 +370,7 @@ getshell () {
# }}} # }}}
# Desktop Environment {{{ # Desktop Environment {{{
getde () { getde() {
case "$os" in case "$os" in
"Mac OS X") de="Aqua" ;; "Mac OS X") de="Aqua" ;;
*) *)
@ -396,7 +396,7 @@ getde () {
# Window Manager {{{ # Window Manager {{{
getwm () { getwm() {
if [ -n "$DISPLAY" ] && [ "$os" != "Mac OS X" ]; then if [ -n "$DISPLAY" ] && [ "$os" != "Mac OS X" ]; then
id="$(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}' 2>/dev/null)" id="$(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}' 2>/dev/null)"
wm="$(xprop -id "$id" -notype -f _NET_WM_NAME 8t 2>/dev/null)" wm="$(xprop -id "$id" -notype -f _NET_WM_NAME 8t 2>/dev/null)"
@ -424,7 +424,7 @@ getwm () {
# Window Manager Theme {{{ # Window Manager Theme {{{
getwmtheme () { getwmtheme() {
[ -z "$wm" ] && getwm [ -z "$wm" ] && getwm
[ -z "$de" ] && getde [ -z "$de" ] && getde
@ -536,7 +536,7 @@ getwmtheme () {
# CPU {{{ # CPU {{{
getcpu () { getcpu() {
# NetBSD emulates the linux /proc filesystem instead of using sysctl for hw # NetBSD emulates the linux /proc filesystem instead of using sysctl for hw
# information so we have to use this block below which temporarily sets the # information so we have to use this block below which temporarily sets the
# OS to 'Linux' for the duration of this function. # OS to 'Linux' for the duration of this function.
@ -790,7 +790,7 @@ getcpu () {
# CPU Usage {{{ # CPU Usage {{{
getcpu_usage () { getcpu_usage() {
case "$os" in case "$os" in
"Windows") "Windows")
cpu_usage="$(wmic cpu get loadpercentage /value)" cpu_usage="$(wmic cpu get loadpercentage /value)"
@ -826,7 +826,7 @@ getcpu_usage () {
# GPU {{{ # GPU {{{
getgpu () { getgpu() {
case "$os" in case "$os" in
"Linux") "Linux")
gpu="$(PATH="/sbin:$PATH" lspci | grep -F "3D")" gpu="$(PATH="/sbin:$PATH" lspci | grep -F "3D")"
@ -1020,7 +1020,7 @@ getgpu () {
# Memory {{{ # Memory {{{
getmemory () { getmemory() {
case "$os" in case "$os" in
"Linux" | "Windows") "Linux" | "Windows")
if grep -F "MemAvail" /proc/meminfo >/dev/null 2>&1; then if grep -F "MemAvail" /proc/meminfo >/dev/null 2>&1; then
@ -1073,7 +1073,7 @@ getmemory () {
# Song {{{ # Song {{{
getsong () { getsong() {
if mpc version >/dev/null 2>&1; then if mpc version >/dev/null 2>&1; then
song="$(mpc current 2>/dev/null)" song="$(mpc current 2>/dev/null)"
state="$(mpc | awk -F '\\[|\\]' '/\[/ {printf $2}' 2>/dev/null)" state="$(mpc | awk -F '\\[|\\]' '/\[/ {printf $2}' 2>/dev/null)"
@ -1153,7 +1153,7 @@ getsong () {
# Resolution {{{ # Resolution {{{
getresolution () { getresolution() {
case "$os" in case "$os" in
"Linux" | "BSD" | "Solaris") "Linux" | "BSD" | "Solaris")
if type -p xrandr >/dev/null 2>&1; then if type -p xrandr >/dev/null 2>&1; then
@ -1207,7 +1207,7 @@ getresolution () {
# Theme/Icons/Font {{{ # Theme/Icons/Font {{{
getstyle () { getstyle() {
# Fix weird output when the function # Fix weird output when the function
# is run multiple times. # is run multiple times.
unset gtk2theme gtk3theme theme path unset gtk2theme gtk3theme theme path
@ -1360,16 +1360,16 @@ getstyle () {
fi fi
} }
gettheme () { gettheme() {
getstyle theme getstyle theme
} }
geticons () { geticons() {
getstyle icons getstyle icons
icons="$theme" icons="$theme"
} }
getfont () { getfont() {
getstyle font getstyle font
font="$theme" font="$theme"
} }
@ -1378,7 +1378,7 @@ getfont () {
# Terminal Emulator {{{ # Terminal Emulator {{{
getterm () { getterm() {
# Check $PPID for terminal emulator. # Check $PPID for terminal emulator.
case "$os" in case "$os" in
"Mac OS X") "Mac OS X")
@ -1420,7 +1420,7 @@ getterm () {
# Terminal Emulator Font {{{ # Terminal Emulator Font {{{
gettermfont () { gettermfont() {
[ -z "$term" ] && getterm [ -z "$term" ] && getterm
case "$term" in case "$term" in
@ -1468,7 +1468,7 @@ gettermfont () {
# Disk Usage {{{ # Disk Usage {{{
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" ;;
@ -1520,7 +1520,7 @@ getdisk () {
# Battery Usage {{{ # Battery Usage {{{
getbattery () { getbattery() {
case "$os" in case "$os" in
"Linux") "Linux")
if [ "$(ls /sys/class/power_supply/)" ]; then if [ "$(ls /sys/class/power_supply/)" ]; then
@ -1616,7 +1616,7 @@ getbattery () {
# IP Address {{{ # IP Address {{{
getlocalip () { getlocalip() {
case "$os" in case "$os" in
"Linux") "Linux")
localip="$(ip route get 1 | awk '{print $NF;exit}')" localip="$(ip route get 1 | awk '{print $NF;exit}')"
@ -1637,7 +1637,7 @@ getlocalip () {
esac esac
} }
getpublicip () { getpublicip() {
if type -p dig >/dev/null 2>&1; then if type -p dig >/dev/null 2>&1; then
publicip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2>/dev/null)" publicip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com 2>/dev/null)"
fi fi
@ -1655,7 +1655,7 @@ getpublicip () {
# Logged In Users {{{ # Logged In Users {{{
getusers () { getusers() {
users="$(who | awk '!seen[$1]++ {printf $1 ", "}')" users="$(who | awk '!seen[$1]++ {printf $1 ", "}')"
users="${users%\,*}" users="${users%\,*}"
} }
@ -1664,7 +1664,7 @@ getusers () {
# Birthday {{{ # Birthday {{{
getbirthday () { getbirthday() {
case "$os" in case "$os" in
"linux" | "iPhone OS") "linux" | "iPhone OS")
birthday="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')" birthday="$(ls -alct --full-time / | awk '/lost\+found|private/ {printf $6 " " $7}')"
@ -1732,7 +1732,7 @@ getbirthday () {
# Terminal colors {{{ # Terminal colors {{{
getcols () { getcols() {
if [ "$color_blocks" == "on" ]; then if [ "$color_blocks" == "on" ]; then
# Convert the width to space chars. # Convert the width to space chars.
block_width="$(printf "%$((block_width-=1))s")" block_width="$(printf "%$((block_width-=1))s")"
@ -1770,7 +1770,7 @@ getcols () {
# Wallpaper {{{ # Wallpaper {{{
getwallpaper () { getwallpaper() {
case "$os" in case "$os" in
"Linux" | "BSD") "Linux" | "BSD")
if type -p feh >/dev/null 2>&1 && [ -f "$HOME/.fehbg" ]; then if type -p feh >/dev/null 2>&1 && [ -f "$HOME/.fehbg" ]; then
@ -1825,7 +1825,7 @@ getwallpaper () {
# Ascii {{{ # Ascii {{{
getascii () { getascii() {
if [ ! -f "$ascii" ] || [ "$ascii" == "distro" ]; then if [ ! -f "$ascii" ] || [ "$ascii" == "distro" ]; then
# Error message # Error message
[ "$ascii" != "distro" ] && \ [ "$ascii" != "distro" ] && \
@ -1890,7 +1890,7 @@ getascii () {
# Image {{{ # Image {{{
getimage () { getimage() {
# Fallback to ascii mode if imagemagick isn't installed. # Fallback to ascii mode if imagemagick isn't installed.
type -p convert >/dev/null 2>&1 || image="ascii" type -p convert >/dev/null 2>&1 || image="ascii"
@ -2063,7 +2063,7 @@ getimage () {
img="$thumbnail_dir/$imgname" img="$thumbnail_dir/$imgname"
} }
takescrot () { takescrot() {
$scrot_cmd "${scrot_dir}${scrot_name}" $scrot_cmd "${scrot_dir}${scrot_name}"
} }
@ -2072,7 +2072,7 @@ takescrot () {
# Find w3m-img {{{ # Find w3m-img {{{
# Find w3mimgdisplay automatically # Find w3mimgdisplay automatically
getw3m_img_path () { getw3m_img_path() {
if [ -x "$w3m_img_path" ]; then if [ -x "$w3m_img_path" ]; then
return return
@ -2105,7 +2105,7 @@ getw3m_img_path () {
# Info {{{ # Info {{{
info () { info() {
# $1 is the subtitle # $1 is the subtitle
subtitle="$1" subtitle="$1"
@ -2162,7 +2162,7 @@ info () {
# Prin {{{ # Prin {{{
prin () { prin() {
string="$1${2:+: $2}" string="$1${2:+: $2}"
# Fix rendering issues with w3m and lines that # Fix rendering issues with w3m and lines that
@ -2194,7 +2194,7 @@ prin () {
# Stdout {{{ # Stdout {{{
stdout () { stdout() {
# Read args early for the separator # Read args early for the separator
stdout_separator_flag="$(awk -F '--stdout_separator ' '{printf $2}' <<< "${args[@]}")" stdout_separator_flag="$(awk -F '--stdout_separator ' '{printf $2}' <<< "${args[@]}")"
stdout_separator_flag="${stdout_separator_flag/ '--'*}" stdout_separator_flag="${stdout_separator_flag/ '--'*}"
@ -2222,7 +2222,7 @@ stdout () {
# Underline {{{ # Underline {{{
getunderline () { getunderline() {
case "$underline_enabled" in case "$underline_enabled" in
"on") "on")
underline="$(printf %"$length"s)" underline="$(printf %"$length"s)"
@ -2236,7 +2236,7 @@ getunderline () {
# Colors {{{ # Colors {{{
colors () { colors() {
# Change color of logo based on distro # Change color of logo based on distro
case "$ascii_distro" in case "$ascii_distro" in
"Arch"* | "Antergos"*) "Arch"* | "Antergos"*)
@ -2378,7 +2378,7 @@ colors () {
setcolors ${ascii_colors[@]} setcolors ${ascii_colors[@]}
} }
setcolors () { setcolors() {
c1="$(color "$1")${ascii_bold}" c1="$(color "$1")${ascii_bold}"
c2="$(color "$2")${ascii_bold}" c2="$(color "$2")${ascii_bold}"
c3="$(color "$3")${ascii_bold}" c3="$(color "$3")${ascii_bold}"
@ -2419,7 +2419,7 @@ setcolors () {
esac esac
} }
color () { color() {
case "$1" in case "$1" in
[0-7]) printf "%b%s" "\033[0m\033[3${1}m" ;; [0-7]) printf "%b%s" "\033[0m\033[3${1}m" ;;
"fg") printf "%b%s" "\033[0m" ;; "fg") printf "%b%s" "\033[0m" ;;
@ -2432,7 +2432,7 @@ color () {
# Bold {{{ # Bold {{{
bold () { bold() {
case "$ascii_bold" in case "$ascii_bold" in
"on") ascii_bold="\033[1m" ;; "on") ascii_bold="\033[1m" ;;
"off") ascii_bold="" ;; "off") ascii_bold="" ;;
@ -2448,7 +2448,7 @@ bold () {
# Linebreak {{{ # Linebreak {{{
getlinebreak () { getlinebreak() {
linebreak=" " linebreak=" "
} }
@ -2482,7 +2482,7 @@ trim() {
# Error {{{ # Error {{{
err () { err() {
err+="$(color 1)[!]$(color fg) $1 err+="$(color 1)[!]$(color fg) $1
" "
} }
@ -2491,7 +2491,7 @@ err () {
# Get script directory {{{ # Get script directory {{{
getscriptdir () { getscriptdir() {
[ "$script_dir" ] && return [ "$script_dir" ] && return
# Use $0 to get the script's physical path. # Use $0 to get the script's physical path.
@ -2513,7 +2513,7 @@ getscriptdir () {
# Source default config {{{ # Source default config {{{
getdefaultconfig () { getdefaultconfig() {
if [ -f "/usr/share/neofetch/config" ]; then if [ -f "/usr/share/neofetch/config" ]; then
default_config="/usr/share/neofetch/config" default_config="/usr/share/neofetch/config"
@ -2536,7 +2536,7 @@ getdefaultconfig () {
# Source Config {{{ # Source Config {{{
getuserconfig () { getuserconfig() {
# Check $config_file # Check $config_file
if [ -f "$config_file" ]; then if [ -f "$config_file" ]; then
source "$config_file" source "$config_file"
@ -2610,7 +2610,7 @@ bar() {
# Cache {{{ # Cache {{{
cache () { cache() {
mkdir -p "$3/neofetch" mkdir -p "$3/neofetch"
echo "${1/*-}=\"$2\"" > "$3/neofetch/${1/*-}" echo "${1/*-}=\"$2\"" > "$3/neofetch/${1/*-}"
} }
@ -2619,7 +2619,7 @@ cache () {
# KDE Config directory {{{ # KDE Config directory {{{
kdeconfigdir () { kdeconfigdir() {
if [ -n "$KDE_CONFIG_DIR" ]; then if [ -n "$KDE_CONFIG_DIR" ]; then
kde_config_dir="$KDE_CONFIG_DIR" kde_config_dir="$KDE_CONFIG_DIR"
@ -2643,7 +2643,7 @@ kdeconfigdir () {
# Usage {{{ # Usage {{{
usage () { cat << EOF usage() { cat << EOF
usage: neofetch --option "value" --option "value" usage: neofetch --option "value" --option "value"
@ -2936,7 +2936,7 @@ while [ "$1" ]; do
readonly memory_display="infobar" readonly memory_display="infobar"
readonly disk_display="infobar" readonly disk_display="infobar"
printinfo () { printinfo() {
if [ "$TRAVIS_OS_NAME" ]; then if [ "$TRAVIS_OS_NAME" ]; then
info linebreak info linebreak
info linebreak info linebreak
@ -2972,7 +2972,7 @@ done
# Call Functions and Finish Up {{{ # Call Functions and Finish Up {{{
main () { main() {
# Restore cursor and clear screen on ctrl+c # Restore cursor and clear screen on ctrl+c
trap 'printf "\033[?25h"; clear; exit' 2 trap 'printf "\033[?25h"; clear; exit' 2