Merge pull request #74 from dylanaraps/kde

Added KDE support to getstyle.
This commit is contained in:
Dylan Araps 2016-02-17 00:12:07 +11:00
commit 071f776914
2 changed files with 45 additions and 19 deletions

View file

@ -28,8 +28,8 @@ printinfo () {
info "Shell" shell info "Shell" shell
info "Desktop Environment" de info "Desktop Environment" de
info "Window Manager" wm info "Window Manager" wm
info "GTK Theme" gtktheme info "Theme" theme
info "Icons" gtkicons info "Icons" icons
info "CPU" cpu info "CPU" cpu
info "GPU" gpu info "GPU" gpu
info "Memory" memory info "Memory" memory

60
fetch
View file

@ -47,8 +47,8 @@ printinfo () {
info "Shell" shell info "Shell" shell
info "Desktop Environment" de info "Desktop Environment" de
info "Window Manager" wm info "Window Manager" wm
info "GTK Theme" gtktheme info "Theme" theme
info "Icons" gtkicons info "Icons" icons
info "CPU" cpu info "CPU" cpu
info "GPU" gpu info "GPU" gpu
info "Memory" memory info "Memory" memory
@ -1158,9 +1158,9 @@ getresolution () {
# }}} # }}}
# GTK Theme/Icons/Font {{{ # Theme/Icons/Font {{{
getgtk () { getstyle () {
# Fix weird output when the function # Fix weird output when the function
# is run multiple times. # is run multiple times.
unset gtk2theme gtk3theme unset gtk2theme gtk3theme
@ -1171,6 +1171,7 @@ getgtk () {
gsettings="gtk-theme" gsettings="gtk-theme"
gconf="gtk_theme" gconf="gtk_theme"
xfconf="ThemeName" xfconf="ThemeName"
kde="widgetStyle"
;; ;;
icons) icons)
@ -1178,6 +1179,7 @@ getgtk () {
gsettings="icon-theme" gsettings="icon-theme"
gconf="icon_theme" gconf="icon_theme"
xfconf="IconThemeName" xfconf="IconThemeName"
kde="Theme"
;; ;;
font) font)
@ -1185,6 +1187,7 @@ getgtk () {
gsettings="font-name" gsettings="font-name"
gconf="font_theme" gconf="font_theme"
xfconf="FontName" xfconf="FontName"
kde="font"
;; ;;
esac esac
@ -1194,6 +1197,29 @@ getgtk () {
desktop=${desktop^} desktop=${desktop^}
case "$desktop" in case "$desktop" in
"KDE"*)
if type -p kde5-config >/dev/null 2>&1; then
kde_config_dir=$(kde5-config --localprefix)
elif type -p kde4-config >/dev/null 2>&1; then
kde_config_dir=$(kde4-config --localprefix)
elif type -p kde-config >/dev/null 2>&1; then
kde_config_dir=$(kde-config --localprefix)
fi
if [ -f "${kde_config_dir}/share/config/kdeglobals" ]; then
kde_config_file="${kde_config_dir}/share/config/kdeglobals"
theme=$(grep "^[^#]*$kde" "$kde_config_file")
theme=${theme/${kde}*=}
theme=${theme^}
gtk_shorthand="on"
return
fi
;;
"Cinnamon") "Cinnamon")
if type -p gsettings >/dev/null 2>&1; then if type -p gsettings >/dev/null 2>&1; then
gtk3theme=$(gsettings get org.cinnamon.desktop.interface $gsettings) gtk3theme=$(gsettings get org.cinnamon.desktop.interface $gsettings)
@ -1274,31 +1300,31 @@ getgtk () {
fi fi
# Final string # Final string
gtktheme="${gtk2theme}${gtk3theme}" theme="${gtk2theme}${gtk3theme}"
# If the final string is empty print "None" # If the final string is empty print "None"
[ -z "$gtktheme" ] && gtktheme="None" [ -z "$theme" ] && theme="None"
# Make the output shorter by removing "[GTKX]" from the string # Make the output shorter by removing "[GTKX]" from the string
if [ "$gtk_shorthand" == "on" ]; then if [ "$gtk_shorthand" == "on" ]; then
gtktheme=${gtktheme/ '[GTK2]'} theme=${theme/ '[GTK2]'}
gtktheme=${gtktheme/ '[GTK3]'} theme=${theme/ '[GTK3]'}
gtktheme=${gtktheme/ '[GTK2/3]'} theme=${theme/ '[GTK2/3]'}
fi fi
} }
getgtktheme () { gettheme () {
getgtk theme getstyle theme
} }
getgtkicons () { geticons () {
getgtk icons getstyle icons
gtkicons="$gtktheme" icons="$theme"
} }
getgtkfont () { getfont () {
getgtk font getstyle font
gtkfont="$gtktheme" font="$theme"
} }
# }}} # }}}