Un-hardcode getgtk formatting and cleanup the function. Added choclatey support for Windows
This commit is contained in:
parent
7d8f10d528
commit
548b54e633
|
@ -83,11 +83,11 @@ https://github.com/dylanaraps/fetch/wiki/Customizing-Info
|
|||
|
||||
**Linux / BSD:**
|
||||
|
||||
- Display Wallpaper: `feh` or `nitrogen`
|
||||
- Display Wallpaper: `feh`, `nitrogen` or `gsettings`
|
||||
- Current Song: `mpc` or `cmus`
|
||||
- Resolution Detection: `xorg-xdpyinfo`
|
||||
- Take a screenshot on script finish: `scrot`
|
||||
- You can change this to another program with a `--scrotcmd` and an in script option.
|
||||
- You can change this to another program with a `--scrot_cmd` and an in script option.
|
||||
|
||||
|
||||
<!-- }}} -->
|
||||
|
|
62
fetch
62
fetch
|
@ -8,12 +8,11 @@
|
|||
# Text formatting, dynamic image size and padding: tput
|
||||
# [Linux / BSD / Windows] Uptime detection: procps or procps-ng
|
||||
#
|
||||
#
|
||||
# Optional Dependencies: (You'll lose these features without them)
|
||||
# Displaying Images: w3m + w3m-img
|
||||
# Image Cropping: ImageMagick
|
||||
# More accurate window manager detection: wmctrl
|
||||
# [ Linux / BSD ] Wallpaper Display: feh or nitrogen
|
||||
# [ Linux / BSD ] Wallpaper Display: feh, nitrogen or gsettings
|
||||
# [ Linux / BSD ] Current Song: mpc or cmus
|
||||
# [ Linux / BSD ] Resolution detection: xorg-xdpyinfo
|
||||
#
|
||||
|
@ -76,7 +75,7 @@ printinfo () {
|
|||
info "GPU" gpu
|
||||
info "Memory" memory
|
||||
|
||||
# info "Font" font
|
||||
# info "Font" gtkfont
|
||||
# info "Disk" disk
|
||||
# info "Resolution" resolution
|
||||
# info "Song" song
|
||||
|
@ -330,13 +329,11 @@ esac
|
|||
|
||||
case "$os" in
|
||||
"Linux" )
|
||||
if type -p crux >/dev/null 2>&1; then
|
||||
distro="CRUX"
|
||||
|
||||
elif type -p lsb_release >/dev/null 2>&1; then
|
||||
if type -p lsb_release >/dev/null 2>&1; then
|
||||
distro="$(lsb_release -a 2>/dev/null | awk -F':' '/Description/ {printf $2}')"
|
||||
distro=${distro/[[:space:]]}
|
||||
|
||||
elif type -p crux >/dev/null 2>&1; then
|
||||
distro="CRUX"
|
||||
else
|
||||
distro="$(grep -h '^NAME=' /etc/*ease)"
|
||||
distro=${distro#NAME\=*}
|
||||
|
@ -432,6 +429,7 @@ getuptime () {
|
|||
hours=$((uptime / 3600%24))
|
||||
days=$((uptime / 86400))
|
||||
|
||||
# Format the output like Linux's "uptime -p" cmd.
|
||||
case "$mins" in
|
||||
0) ;;
|
||||
1) uptime="up $mins minute" ;;
|
||||
|
@ -462,6 +460,7 @@ getuptime () {
|
|||
|
||||
esac
|
||||
|
||||
# Make the output of uptime smaller.
|
||||
case "$uptime_shorthand" in
|
||||
"on")
|
||||
uptime=${uptime/up}
|
||||
|
@ -550,6 +549,12 @@ getpackages () {
|
|||
|
||||
"Windows"*)
|
||||
packages=$(cygcheck -cd | wc -l)
|
||||
|
||||
# Count chocolatey packages
|
||||
if [ -d "/cygdrive/c/ProgramData/chocolatey/lib" ]; then
|
||||
choco_packages=$(ls -1 /cygdrive/c/ProgramData/chocolatey/lib | wc -l)
|
||||
packages=$((packages + choco_packages))
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
|
@ -978,6 +983,7 @@ getgtk () {
|
|||
esac
|
||||
|
||||
# Check for gtk2 theme
|
||||
if [ "$gtk2" == "on" ]; then
|
||||
if [ -f "$HOME/.gtkrc-2.0" ]; then
|
||||
gtk2theme=$(grep "^[^#]*$name" "$HOME/.gtkrc-2.0")
|
||||
|
||||
|
@ -985,7 +991,12 @@ getgtk () {
|
|||
gtk2theme=$(grep "^[^#]*$name" /etc/gtk-2.0/gtkrc)
|
||||
fi
|
||||
|
||||
gtk2theme=${gtk2theme/${name}*=}
|
||||
gtk2theme=${gtk2theme//\"}
|
||||
fi
|
||||
|
||||
# Check for gtk3 theme
|
||||
if [ "$gtk3" == "on" ]; then
|
||||
if type -p gsettings >/dev/null 2>&1; then
|
||||
gtk3theme="$(gsettings get org.gnome.desktop.interface $gsettings)"
|
||||
gtk3theme=${gtk3theme//\'}
|
||||
|
@ -997,36 +1008,29 @@ getgtk () {
|
|||
gtk3theme=$(grep "^[^#]*$name" /etc/gtk-3.0/settings.ini)
|
||||
fi
|
||||
|
||||
# Format the strings
|
||||
gtk2theme=${gtk2theme/${name}*=}
|
||||
gtk2theme=${gtk2theme//\"}
|
||||
|
||||
[ "$gtk2theme" ] && \
|
||||
gtk2theme="$gtk2theme [GTK2], "
|
||||
|
||||
# Format the string
|
||||
gtk3theme=${gtk3theme/${name}*=}
|
||||
gtk3theme=${gtk3theme//\"}
|
||||
gtk3theme=${gtk3theme/[[:space:]]/ }
|
||||
gtktheme="${gtk2theme}${gtk3theme} [GTK3] "
|
||||
fi
|
||||
|
||||
# Check to see if gtk2 and gtk3 theme are identical
|
||||
# Format the string based on which themes exist
|
||||
if [ "$gtk2theme" ] && [ "$gtk2theme" == "$gtk3theme" ]; then
|
||||
gtktheme="$gtk2theme [GTK2/3]"
|
||||
gtk3theme+=" [GTK2/3]"
|
||||
unset gtk2theme
|
||||
|
||||
elif [ -z "$gtk2theme" ] && [ -z "$gtk3theme" ]; then
|
||||
gtktheme="None"
|
||||
elif [ "$gtk2theme" ] && [ "$gtk3theme" ]; then
|
||||
gtk2theme+=" [GTK2], "
|
||||
gtk3theme+=" [GTK3] "
|
||||
else
|
||||
[ "$gtk2theme" ] && gtk2theme+=" [GTK2] "
|
||||
[ "$gtk3theme" ] && gtk3theme+=" [GTK3] "
|
||||
fi
|
||||
|
||||
# Hide gtk2 from gtk theme output
|
||||
if [ "$gtk2" == "off" ]; then
|
||||
gtktheme=${gtktheme/*'[GTK2], '}
|
||||
fi
|
||||
# Final string
|
||||
gtktheme="${gtk2theme}${gtk3theme}"
|
||||
|
||||
# Hide gtk3 from gtk theme output
|
||||
if [ "$gtk3" == "off" ]; then
|
||||
gtktheme=${gtktheme/'[GTK2],'*/'[GTK2]'}
|
||||
fi
|
||||
# If the final string is empty print "None"
|
||||
[ -z "$gtktheme" ] && gtktheme="None"
|
||||
|
||||
# Make the output shorter by removing "[GTKX]" from the string
|
||||
if [ "$gtk_shorthand" == "on" ]; then
|
||||
|
|
Reference in New Issue