Added folds for function so that it's easier to navigate the script inside vim

This commit is contained in:
Dylan 2016-01-26 23:06:53 +11:00
parent 5145f40125
commit a3446428e8
1 changed files with 100 additions and 17 deletions

117
fetch
View File

@ -146,7 +146,6 @@ block_width=3
# }}} # }}}
# Text Colors {{{ # Text Colors {{{
# --colors 1 2 3 4 5 # --colors 1 2 3 4 5
@ -173,7 +172,6 @@ info_color=6
# }}} # }}}
# Text Options {{{ # Text Options {{{
@ -202,7 +200,6 @@ prompt_height=1
# }}} # }}}
# Image Options {{{ # Image Options {{{
@ -266,7 +263,6 @@ xoffset=0
# }}} # }}}
# Other Options {{{ # Other Options {{{
@ -298,7 +294,8 @@ scrot_name="fetch-%Y-%m-%d-%H:%M.png"
# Gather Info {{{ # Gather Info {{{
# Get Operating System Type # Operating System {{{
case "$(uname)" in case "$(uname)" in
"Linux") "Linux")
os="Linux" os="Linux"
@ -326,7 +323,10 @@ case "$(uname)" in
;; ;;
esac esac
# Get Distro # }}}
# Distro {{{
case "$os" in case "$os" in
"Linux" ) "Linux" )
if type -p crux >/dev/null 2>&1; then if type -p crux >/dev/null 2>&1; then
@ -390,17 +390,26 @@ case "$os" in
;; ;;
esac esac
# Get Title # }}}
# Title {{{
gettitle () { gettitle () {
title="${USER}@$(hostname)" title="${USER}@$(hostname)"
} }
# Get kernel version # }}}
# Kernel {{{
getkernel() { getkernel() {
kernel="$(uname -r)" kernel="$(uname -r)"
} }
# Get uptime # }}}
# Uptime {{{
getuptime () { getuptime () {
case "$os" in case "$os" in
"Linux") "Linux")
@ -474,7 +483,10 @@ getuptime () {
esac esac
} }
# Get package count # }}}
# Package Count {{{
getpackages () { getpackages () {
case "$distro" in case "$distro" in
"Arch Linux"* | "Parabola GNU/Linux-libre"* | "Manjaro"* | "Antergos"*) "Arch Linux"* | "Parabola GNU/Linux-libre"* | "Manjaro"* | "Antergos"*)
@ -547,12 +559,18 @@ getpackages () {
packages=${packages// } packages=${packages// }
} }
# Get shell # }}}
# Shell {{{
getshell () { getshell () {
shell="$SHELL" shell="$SHELL"
} }
# Get window manager # }}}
# Window Manager {{{
getwindowmanager () { getwindowmanager () {
if type -p wmctrl >/dev/null 2>&1; then if type -p wmctrl >/dev/null 2>&1; then
windowmanager="$(wmctrl -m | head -n1)" windowmanager="$(wmctrl -m | head -n1)"
@ -585,7 +603,10 @@ getwindowmanager () {
fi fi
} }
# Get cpu # }}}
# CPU {{{
getcpu () { getcpu () {
case "$os" in case "$os" in
"Linux") "Linux")
@ -708,6 +729,10 @@ getcpu () {
cpu=${cpu// with Radeon HD Graphics} cpu=${cpu// with Radeon HD Graphics}
} }
# }}}
# GPU {{{
getgpu () { getgpu () {
case "$os" in case "$os" in
"Linux") "Linux")
@ -800,7 +825,10 @@ getgpu () {
fi fi
} }
# Get memory # }}}
# Memory {{{
getmemory () { getmemory () {
case "$os" in case "$os" in
"Linux") "Linux")
@ -888,7 +916,10 @@ getmemory () {
esac esac
} }
# Get song # }}}
# Song {{{
getsong () { getsong () {
if type -p mpc >/dev/null 2>&1; then if type -p mpc >/dev/null 2>&1; then
song="$(mpc current)" song="$(mpc current)"
@ -904,7 +935,10 @@ getsong () {
fi fi
} }
# Get Resolution # }}}
# Resolution {{{
getresolution () { getresolution () {
case "$os" in case "$os" in
"Linux" | *"BSD") "Linux" | *"BSD")
@ -920,6 +954,10 @@ getresolution () {
[ -z "$resolution" ] && resolution="Unknown" [ -z "$resolution" ] && resolution="Unknown"
} }
# }}}
# GTK Theme/Icons/Font {{{
getgtk () { getgtk () {
case "$1" in case "$1" in
theme) theme)
@ -1011,6 +1049,10 @@ getgtkfont () {
gtkfont="$gtktheme" gtkfont="$gtktheme"
} }
# }}}
# Disk Usage {{{
getdisk () { getdisk () {
# df flags # df flags
case "$os" in case "$os" in
@ -1038,6 +1080,10 @@ getdisk () {
disk="${disk_used} / ${disk_total} (${disk_total_per})" disk="${disk_used} / ${disk_total} (${disk_total_per})"
} }
# }}}
# Terminal colors {{{
getcols () { getcols () {
if [ "$color_blocks" == "on" ]; then if [ "$color_blocks" == "on" ]; then
printf "${padding}%s" printf "${padding}%s"
@ -1055,8 +1101,9 @@ getcols () {
fi fi
} }
# }}}
# Windows Specific Functions # Windows Specific Functions {{{
getvisualstyle () { getvisualstyle () {
case "$os" in case "$os" in
@ -1075,6 +1122,8 @@ getvisualstyle () {
esac esac
} }
# }}}
# }}} # }}}
@ -1082,6 +1131,8 @@ getvisualstyle () {
# Images {{{ # Images {{{
# Wallpaper {{{
getwallpaper () { getwallpaper () {
case "$os" in case "$os" in
"Linux" | *"BSD") "Linux" | *"BSD")
@ -1119,11 +1170,19 @@ getwallpaper () {
esac esac
} }
# }}}
# Shuffle {{{
getshuffle () { getshuffle () {
img=$(find "$shuffledir" -type f \( -name '*.jpg' -o -name '*.png' \) -print0 | img=$(find "$shuffledir" -type f \( -name '*.jpg' -o -name '*.png' \) -print0 |
shuf -n1 -z) shuf -n1 -z)
} }
# }}}
# Image {{{
getimage () { getimage () {
# Make the directory if it doesn't exist # Make the directory if it doesn't exist
mkdir -p "$imgtempdir" mkdir -p "$imgtempdir"
@ -1243,9 +1302,14 @@ takescrot () {
# }}} # }}}
# }}}
# Text Formatting {{{ # Text Formatting {{{
# Info {{{
info () { info () {
# Call the function and update variable # Call the function and update variable
if [ -z "$2" ]; then if [ -z "$2" ]; then
@ -1281,6 +1345,10 @@ info () {
printf "%b%s\n" "${padding}${string}${clear}" printf "%b%s\n" "${padding}${string}${clear}"
} }
# }}}
# Prin {{{
prin () { prin () {
case "$1" in case "$1" in
*:*) *:*)
@ -1301,11 +1369,19 @@ prin () {
printf "%b%s\n" "${padding}${string}${clear}" printf "%b%s\n" "${padding}${string}${clear}"
} }
# }}}
# Underline {{{
getunderline () { getunderline () {
underline=$(printf %"$length"s) underline=$(printf %"$length"s)
underline=${underline// /$underline_char} underline=${underline// /$underline_char}
} }
# }}}
# Colors {{{
colors () { colors () {
title_color="\e[38;5;${title_color}m" title_color="\e[38;5;${title_color}m"
at_color="\e[38;5;${at_color}m" at_color="\e[38;5;${at_color}m"
@ -1319,6 +1395,10 @@ color () {
printf "%b%s" "\e[38;5;${1}m" printf "%b%s" "\e[38;5;${1}m"
} }
# }}}
# Bold {{{
bold () { bold () {
if [ "$bold" == "on" ]; then if [ "$bold" == "on" ]; then
bold="\e[1m" bold="\e[1m"
@ -1327,6 +1407,9 @@ bold () {
fi fi
} }
# }}}
clear="\e[0m" clear="\e[0m"