Merge pull request #6 from atyoung/master

RE: Hotfix 003aa69a of my other hotfix  + Fixed / Added LXDE Support
This commit is contained in:
Brett Bohnenkamper
2011-05-09 01:56:14 -07:00

View File

@@ -1,6 +1,6 @@
#!/bin/bash
#
# screenFetch (v2.3.2)
# screenFetch (v2.3.3)
#
# Script to fetch system and theme settings for screenshots in most mainstream
# Linux distributions.
@@ -12,7 +12,7 @@
# very hard on this and am quite proud to call this script my own.
#
# Yes, I do realize some of this is horribly ugly coding. Any ideas/suggestions would be
# appreciated by emailing me or by stopping by http://github.com/KittyKatt/screeFetch . You
# appreciated by emailing me or by stopping by http://github.com/KittyKatt/screenFetch . You
# could also drop in on my IRC network, SilverIRC, at irc://kittykatt.silverirc.com:6667/meowz
# to put forth suggestions/ideas. Thank you.
#
@@ -94,7 +94,7 @@ while getopts ":hsmevVntlc:D:o:B" flags; do
echo ""
echo -e "${underline}Supported Distributions${c0}: Arch Linux (Old and Current Logos), Linux Mint,"
echo -e " Ubuntu, Crunchbang, Debian, Gentoo, Fedora,"
echo -e " Mandrake/Mandriva, Slackware, SUSE, and BSD"
echo -e " Mandrake/Mandriva, Slackware, openSUSE, and BSD"
echo -e "${underline}Supported Desktop Managers${c0}: KDE, GNOME, XFCE, and LXDE, and Not Present"
echo -e "${underline}Supported Window Managers${c0}: PekWM, OpenBox, FluxBox, BlackBox, Xfwm4,"
echo -e " Metacity, StumpWM, KWin, IceWM, FVWM,"
@@ -117,7 +117,7 @@ while getopts ":hsmevVntlc:D:o:B" flags; do
echo -e " ${bold}-s(m)${c0} Using this flag tells the script that you want it"
echo -e " to take a screenshot. Use the -m flag if you would like"
echo -e " to move it to a new location afterwards."
echo -e " ${bold}-B${c0} Enable background detection."
echo -e " ${bold}-B${c0} Enable background detection."
echo -e " ${bold}-e${c0} When this flag is specified, screenFetch will attempt"
echo -e " to export all of your theme settings and archive them"
echo -e " up for uploading."
@@ -247,7 +247,7 @@ detectdistro () {
if [ -f /etc/fedora-release ]; then distro="Fedora"; fi
if [ -f /etc/redhat-release ]; then distro="Red Hat Linux"; fi
if [ -f /etc/slackware-version ]; then distro="Slackware"; fi
if [ -f /etc/SuSE-release ]; then distro="OpenSuSe"; fi
if [ -f /etc/SuSE-release ]; then distro="openSUSE"; fi
if [ -f /etc/mandrake-release ]; then distro="Mandrake"; fi
if [ -f /etc/mandriva-release ]; then distro="Mandriva"; fi
if [ -f /etc/crunchbang-lsb-release ]; then distro="CrunchBang"; fi
@@ -255,7 +255,33 @@ detectdistro () {
if [ -f /var/run/dmesg.boot ] && grep -i bsd /var/run/dmesg.boot; then distro="BSD"; fi
if [ -f /usr/share/doc/tc/release.txt ]; then distro="TinyCore"; fi
fi
fi
else
declare -l lcase
lcase=$distro
case $lcase in
arch*linux*old) distro="Arch Linux - Old" ;;
arch*linux) distro="Arch Linux" ;;
fedora) distro="Fedora" ;;
mandriva) distro="Mandriva" ;;
mandrake) distro="Mandrake" ;;
mint) distro="Mint" ;;
lmde) distro="LMDE" ;;
opensuse) distro="OpenSuSe" ;;
ubuntu) distro="Ubuntu" ;;
debain) distro="Debian" ;;
bsd) distro="BSD" ;;
red*hat*) distro="Red Hat Linux" ;;
crunchbang) distro="CrunchBang" ;;
gentoo) distro="Gentoo" ;;
slackware) distro="Slackware" ;;
esac
fi
[[ "$verbosity" -eq "1" ]] && verboseOut "Finding distro...found as '$distro $distro_release'"
}
# Distro Detection - End
@@ -318,7 +344,7 @@ detectde () {
[ "$each" == "gnome-session" -o "$each" == "gnome-settings-daemon" ] && DE="GNOME" && DEver=$(gnome-session --version | awk {'print $NF'})
[ "$each" == "xfce4-session" ] && DE="XFCE" && DEver=$(xfce4-settings-manager --version | grep -m 1 "" | awk {'print $2'})
[ "$each" == "ksmserver" ] && DE="KDE" && DEver=$(kwin --version | awk '/^Qt/ {data="Qt v" $2};/^KDE/ {data=$2 " (" data ")"};END{print data}')
[ "$each" == "lxsession" ] && DE="LXDE"
[ "$each" == "lxsession" ] && DE="LXDE" && DEver=$(lxpanel -v)
fi
done
[[ "$verbosity" -eq "1" ]] && verboseOut "Finding desktop environment...found as '$DE'"
@@ -373,7 +399,12 @@ detectwmtheme () {
Win_theme="Not Found"
case $WM in
'PekWM') if [ -f $HOME/.pekwm/config ]; then Win_theme="$(awk -F"/" '/Theme/ {gsub(/\"/,""); print $NF}' $HOME/.pekwm/config)"; fi;;
'OpenBox') if [ -f ${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/rc.xml ]; then Win_theme="$(awk -F"[<,>]" '/<theme/ { getline; print $3 }' ${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/rc.xml)"; elif [ -f ${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/lxde-rc.xml ]; then Win_theme="$(awk -F"[<,>]" '/<theme/ { getline; print $3 }' ${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/lxde-rc.xml)"; fi;;
'OpenBox')
if [ -f ${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/rc.xml ]; then
Win_theme="$(awk -F"[<,>]" '/<theme/ { getline; print $3 }' ${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/rc.xml)";
elif [[ -f ${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/lxde-rc.xml && $DE == "LXDE" ]]; then
Win_theme="$(awk -F"[<,>]" '/<theme/ { getline; print $3 }' ${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/lxde-rc.xml)";
fi;;
'FluxBox') if [ -f $HOME/.fluxbox/init ]; then Win_theme="$(awk -F"/" '/styleFile/ {print $NF}' $HOME/.fluxbox/init)"; fi;;
'BlackBox') if [ -f $HOME/.blackboxrc ]; then Win_theme="$(awk -F"/" '/styleFile/ {print $NF}' $HOME/.blackboxrc)"; fi;;
'Metacity') if [ "`gconftool-2 -g /apps/metacity/general/theme`" ]; then Win_theme="$(gconftool-2 -g /apps/metacity/general/theme)"; fi ;;
@@ -459,6 +490,26 @@ detectgtk () {
gtkFont=$(xfconf-query -c xsettings -p /Gtk/FontName)
fi
;;
'LXDE')
if [ -f ${XDG_CONFIG_HOME:-${HOME}/.config}/lxde/config ]; then
lxdeconf="/lxde/config"
else
lxdeconf="/lxsession/LXDE/desktop.conf"
fi
#TODO: Clean me.
if grep -q "sNet\/ThemeName" ${XDG_CONFIG_HOME:-${HOME}/.config}$lxdeconf; then
gtkTheme=$(awk -F'=' '/sNet\/ThemeName/ {print $2}' ${XDG_CONFIG_HOME:-${HOME}/.config}$lxdeconf)
fi
if grep -q IconThemeName ${XDG_CONFIG_HOME:-${HOME}/.config}$lxdeconf; then
gtkIcons=$(awk -F'=' '/sNet\/IconThemeName/ {print $2}' ${XDG_CONFIG_HOME:-${HOME}/.config}$lxdeconf)
fi
if grep -q FontName ${XDG_CONFIG_HOME:-${HOME}/.config}$lxdeconf; then
gtkFont=$(awk -F'=' '/sGtk\/FontName/ {print $2}' ${XDG_CONFIG_HOME:-${HOME}/.config}$lxdeconf)
fi
;;
# /home/me/.config/rox.sourceforge.net/ROX-Session/Settings.xml
@@ -475,19 +526,6 @@ detectgtk () {
if grep -q font $HOME/.gtkrc-2.0; then
gtkFont=$(awk -F'"' '/gtk-font-name/ {print $2}' $HOME/.gtkrc-2.0)
fi
# LXDE
elif [ -f ${XDG_CONFIG_HOME:-${HOME}/.config}/lxde/config ]; then
if grep -q "sNet\/ThemeName" ${XDG_CONFIG_HOME:-${HOME}/.config}/lxde/config; then
gtkTheme=$(awk -F'=' '/sNet\/ThemeName/ {print $2}' ${XDG_CONFIG_HOME:-${HOME}/.config}/lxde/config)
fi
if grep -q IconThemeName ${XDG_CONFIG_HOME:-${HOME}/.config}/lxde/config; then
gtkIcons=$(awk -F'=' '/sNet\/IconThemeName/ {print $2}' ${XDG_CONFIG_HOME:-${HOME}/.config}/lxde/config)
fi
if grep -q FontName ${XDG_CONFIG_HOME:-${HOME}/.config}/lxde/config; then
gtkFont=$(awk -F'=' '/sGtk\/FontName/ {print $2}' ${XDG_CONFIG_HOME:-${HOME}/.config}/lxde/config)
fi
fi
# $HOME/.gtkrc.mine theme detect only
if [ -f $HOME/.gtkrc.mine ]; then
@@ -573,7 +611,7 @@ case $distro in
"$c1 [LKDSDJTDU=OUSCSBFLD.$c2 '?ZWX, %s"
"$c1 ,LMDSDSWH' \`DCBOSI$c2 DRDS], %s"
"$c1 SDDFDFH' !YEWD,$c2 )HDROD %s"
"$c1 !KMDOCG &GSU|$c2\_GFHRGO\' %s"
"$c1 !KMDOCG &GSU|$c2\_GFHRGO\' %s"
"$c1 HKLSGP'$c2 __$c1\TKM0$c2\GHRBV)' %s"
"$c1 JSNRVW'$c2 __+MNAEC$c1\IOI,$c2\BN' %s"
"$c1 HELK['$c2 __,=OFFXCBGHC$c1\FD) %s"
@@ -612,7 +650,7 @@ case $distro in
c2="\e[1;32m" # Bold Green
startline="1"
fulloutput=("$c2 MMMMMMMMMMMMMMMMMMMMMMMMMmds+."
"$c2 MMm----::-://////////////oymNMd+\` %s"
"$c2 MMm----::-://////////////oymNMd+\` %s"
"$c2 MMd "$c1"/++ "$c2"-sNMd: %s"
"$c2 MMNso/\` "$c1"dMM \`.::-. .-::.\` "$c2".hMN: %s"
"$c2 ddddMMh "$c1"dMM :hNMNMNhNMNMNh: "$c2"\`NMm %s"
@@ -814,7 +852,7 @@ case $distro in
"$c1 -/+ooo+/-. $c2\`")
;;
"OpenSuSe")
"openSUSE")
c1="\e[1;32m" # Bold Green
c2="\e[1;37m" # Bold White
startline="3"
@@ -953,7 +991,7 @@ infoDisplay () {
case $distro in
"Arch Linux - Old"|"Fedora"|"Mandriva"|"Mandrake") labelcolor="\e[1;34m";;
"Arch Linux") labelcolor="\e[1;36m";;
"Mint"|"LMDE"|"OpenSuSe") labelcolor="\e[1;32m";;
"Mint"|"LMDE"|"openSUSE") labelcolor="\e[1;32m";;
"Ubuntu"|"Debian"|"BSD"|"Red Hat Linux") labelcolor="\e[1;31m";;
"CrunchBang") labelcolor="\e[1;30m";;
"Gentoo") labelcolor="\e[1;35m";;
@@ -1120,9 +1158,9 @@ themeExport () {
for i in "${display[@]}"; do
if [[ $i == wmtheme ]]; then
detectwm
detectwmtheme
if [[ $i =~ wm ]]; then
! [[ $WM ]] && detectwm;
! [[ $Win_theme ]] && detectwmtheme;
else
[[ "${display[*]}" =~ "$i" ]] && detect${i}