Remove getvisualstyle and merge it with getstyle
This commit is contained in:
parent
c151f41067
commit
c7fa222ede
236
fetch
236
fetch
|
@ -1176,9 +1176,6 @@ getresolution () {
|
||||||
# Theme/Icons/Font {{{
|
# Theme/Icons/Font {{{
|
||||||
|
|
||||||
getstyle () {
|
getstyle () {
|
||||||
# If X isn't running don't print the theme.
|
|
||||||
[ ! -n "$DISPLAY" ] && return
|
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -1190,6 +1187,8 @@ getstyle () {
|
||||||
gconf="gtk_theme"
|
gconf="gtk_theme"
|
||||||
xfconf="ThemeName"
|
xfconf="ThemeName"
|
||||||
kde="widgetStyle"
|
kde="widgetStyle"
|
||||||
|
path="/proc/registry/HKEY_CURRENT_USER/Software/Microsoft"
|
||||||
|
path+="/Windows/CurrentVersion/Themes/CurrentTheme"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
icons)
|
icons)
|
||||||
|
@ -1209,127 +1208,139 @@ getstyle () {
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Current DE
|
if [ -n "$DISPLAY" ]; then
|
||||||
desktop="$XDG_CURRENT_DESKTOP"
|
# Current DE
|
||||||
desktop=${desktop,,}
|
desktop="$XDG_CURRENT_DESKTOP"
|
||||||
desktop=${desktop^}
|
desktop=${desktop,,}
|
||||||
|
desktop=${desktop^}
|
||||||
|
|
||||||
case "$desktop" in
|
case "$desktop" in
|
||||||
"KDE"*)
|
"KDE"*)
|
||||||
if type -p kde5-config >/dev/null 2>&1; then
|
if type -p kde5-config >/dev/null 2>&1; then
|
||||||
kde_config_dir=$(kde5-config --localprefix)
|
kde_config_dir=$(kde5-config --localprefix)
|
||||||
|
|
||||||
elif type -p kde4-config >/dev/null 2>&1; then
|
elif type -p kde4-config >/dev/null 2>&1; then
|
||||||
kde_config_dir=$(kde4-config --localprefix)
|
kde_config_dir=$(kde4-config --localprefix)
|
||||||
|
|
||||||
elif type -p kde-config >/dev/null 2>&1; then
|
elif type -p kde-config >/dev/null 2>&1; then
|
||||||
kde_config_dir=$(kde-config --localprefix)
|
kde_config_dir=$(kde-config --localprefix)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "${kde_config_dir}/share/config/kdeglobals" ]; then
|
if [ -f "${kde_config_dir}/share/config/kdeglobals" ]; then
|
||||||
kde_config_file="${kde_config_dir}/share/config/kdeglobals"
|
kde_config_file="${kde_config_dir}/share/config/kdeglobals"
|
||||||
|
|
||||||
theme=$(grep "^[^#]*$kde" "$kde_config_file")
|
theme=$(grep "^[^#]*$kde" "$kde_config_file")
|
||||||
theme=${theme/${kde}*=}
|
theme=${theme/${kde}*=}
|
||||||
theme=${theme^}
|
theme=${theme^}
|
||||||
|
|
||||||
gtk_shorthand="on"
|
gtk_shorthand="on"
|
||||||
return
|
return
|
||||||
fi
|
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)
|
||||||
gtk3theme=${gtk3theme//"'"}
|
gtk3theme=${gtk3theme//"'"}
|
||||||
|
gtk2theme=${gtk3theme}
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
"Gnome"* | "Unity"* | "Budgie")
|
||||||
|
if type -p gsettings >/dev/null 2>&1; then
|
||||||
|
gtk3theme=$(gsettings get org.gnome.desktop.interface $gsettings)
|
||||||
|
gtk3theme=${gtk3theme//"'"}
|
||||||
|
gtk2theme=${gtk3theme}
|
||||||
|
|
||||||
|
elif type -p gconftool-2 >/dev/null 2>&1; then
|
||||||
|
gtk2theme=$(gconftool-2 -g /desktop/gnome/interface/$gconf)
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
"Mate"*)
|
||||||
|
gtk3theme=$(gsettings get org.mate.interface $gsettings)
|
||||||
gtk2theme=${gtk3theme}
|
gtk2theme=${gtk3theme}
|
||||||
|
;;
|
||||||
|
|
||||||
|
"Xfce"*)
|
||||||
|
if type -p xfconf-query >/dev/null 2>&1; then
|
||||||
|
gtk2theme=$(xfconf-query -c xsettings -p /Net/$xfconf)
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Check for gtk2 theme
|
||||||
|
if [ -z "$gtk2theme" ]; then
|
||||||
|
if [ -f "$HOME/.gtkrc-2.0" ]; then
|
||||||
|
gtk2theme=$(grep "^[^#]*$name" "$HOME/.gtkrc-2.0")
|
||||||
|
|
||||||
|
elif [ -f "/etc/gtk-2.0/gtkrc" ]; then
|
||||||
|
gtk2theme=$(grep "^[^#]*$name" /etc/gtk-2.0/gtkrc)
|
||||||
fi
|
fi
|
||||||
;;
|
|
||||||
|
|
||||||
"Gnome"* | "Unity"* | "Budgie")
|
gtk2theme=${gtk2theme/${name}*=}
|
||||||
if type -p gsettings >/dev/null 2>&1; then
|
gtk2theme=${gtk2theme//\"}
|
||||||
gtk3theme=$(gsettings get org.gnome.desktop.interface $gsettings)
|
|
||||||
gtk3theme=${gtk3theme//"'"}
|
|
||||||
gtk2theme=${gtk3theme}
|
|
||||||
|
|
||||||
elif type -p gconftool-2 >/dev/null 2>&1; then
|
|
||||||
gtk2theme=$(gconftool-2 -g /desktop/gnome/interface/$gconf)
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
|
|
||||||
"Mate"*)
|
|
||||||
gtk3theme=$(gsettings get org.mate.interface $gsettings)
|
|
||||||
gtk2theme=${gtk3theme}
|
|
||||||
;;
|
|
||||||
|
|
||||||
"Xfce"*)
|
|
||||||
if type -p xfconf-query >/dev/null 2>&1; then
|
|
||||||
gtk2theme=$(xfconf-query -c xsettings -p /Net/$xfconf)
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Check for gtk2 theme
|
|
||||||
if [ -z "$gtk2theme" ]; then
|
|
||||||
if [ -f "$HOME/.gtkrc-2.0" ]; then
|
|
||||||
gtk2theme=$(grep "^[^#]*$name" "$HOME/.gtkrc-2.0")
|
|
||||||
|
|
||||||
elif [ -f "/etc/gtk-2.0/gtkrc" ]; then
|
|
||||||
gtk2theme=$(grep "^[^#]*$name" /etc/gtk-2.0/gtkrc)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gtk2theme=${gtk2theme/${name}*=}
|
# Check for gtk3 theme
|
||||||
gtk2theme=${gtk2theme//\"}
|
if [ -z "$gtk3theme" ]; then
|
||||||
fi
|
if [ -f "$HOME/.config/gtk-3.0/settings.ini" ]; then
|
||||||
|
gtk3theme=$(grep "^[^#]*$name" "$HOME/.config/gtk-3.0/settings.ini")
|
||||||
|
|
||||||
# Check for gtk3 theme
|
elif type -p gsettings >/dev/null 2>&1; then
|
||||||
if [ -z "$gtk3theme" ]; then
|
gtk3theme="$(gsettings get org.gnome.desktop.interface $gsettings)"
|
||||||
if [ -f "$HOME/.config/gtk-3.0/settings.ini" ]; then
|
gtk3theme=${gtk3theme//\'}
|
||||||
gtk3theme=$(grep "^[^#]*$name" "$HOME/.config/gtk-3.0/settings.ini")
|
|
||||||
|
|
||||||
elif type -p gsettings >/dev/null 2>&1; then
|
else
|
||||||
gtk3theme="$(gsettings get org.gnome.desktop.interface $gsettings)"
|
gtk3theme=$(grep "^[^#]*$name" /etc/gtk-3.0/settings.ini)
|
||||||
gtk3theme=${gtk3theme//\'}
|
fi
|
||||||
|
|
||||||
|
gtk3theme=${gtk3theme/${name}*=}
|
||||||
|
gtk3theme=${gtk3theme//\"}
|
||||||
|
gtk3theme=${gtk3theme/[[:space:]]/ }
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Toggle visibility of gtk themes.
|
||||||
|
[ "$gtk2" == "off" ] && unset gtk2theme
|
||||||
|
[ "$gtk3" == "off" ] && unset gtk3theme
|
||||||
|
|
||||||
|
# Format the string based on which themes exist
|
||||||
|
if [ "$gtk2theme" ] && [ "$gtk2theme" == "$gtk3theme" ]; then
|
||||||
|
gtk3theme+=" [GTK2/3]"
|
||||||
|
unset gtk2theme
|
||||||
|
|
||||||
|
elif [ "$gtk2theme" ] && [ "$gtk3theme" ]; then
|
||||||
|
gtk2theme+=" [GTK2], "
|
||||||
|
gtk3theme+=" [GTK3] "
|
||||||
else
|
else
|
||||||
gtk3theme=$(grep "^[^#]*$name" /etc/gtk-3.0/settings.ini)
|
[ "$gtk2theme" ] && gtk2theme+=" [GTK2] "
|
||||||
|
[ "$gtk3theme" ] && gtk3theme+=" [GTK3] "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gtk3theme=${gtk3theme/${name}*=}
|
# Final string
|
||||||
gtk3theme=${gtk3theme//\"}
|
theme="${gtk2theme}${gtk3theme}"
|
||||||
gtk3theme=${gtk3theme/[[:space:]]/ }
|
theme=${theme//\"}
|
||||||
fi
|
theme=${theme//\'}
|
||||||
|
|
||||||
# Toggle visibility of gtk themes.
|
# If the final string is empty print "None"
|
||||||
[ "$gtk2" == "off" ] && unset gtk2theme
|
[ -z "$theme" ] && theme="None"
|
||||||
[ "$gtk3" == "off" ] && unset gtk3theme
|
|
||||||
|
|
||||||
# Format the string based on which themes exist
|
# Make the output shorter by removing "[GTKX]" from the string
|
||||||
if [ "$gtk2theme" ] && [ "$gtk2theme" == "$gtk3theme" ]; then
|
if [ "$gtk_shorthand" == "on" ]; then
|
||||||
gtk3theme+=" [GTK2/3]"
|
theme=${theme/ '[GTK2]'}
|
||||||
unset gtk2theme
|
theme=${theme/ '[GTK3]'}
|
||||||
|
theme=${theme/ '[GTK2/3]'}
|
||||||
elif [ "$gtk2theme" ] && [ "$gtk3theme" ]; then
|
fi
|
||||||
gtk2theme+=" [GTK2], "
|
|
||||||
gtk3theme+=" [GTK3] "
|
|
||||||
else
|
else
|
||||||
[ "$gtk2theme" ] && gtk2theme+=" [GTK2] "
|
case "$os" in
|
||||||
[ "$gtk3theme" ] && gtk3theme+=" [GTK3] "
|
"Windows")
|
||||||
fi
|
theme="$(head -n1 $path 2>/dev/null)"
|
||||||
|
theme="${theme##*\\}"
|
||||||
|
theme="${theme%.*}"
|
||||||
|
theme="${theme^}"
|
||||||
|
;;
|
||||||
|
|
||||||
# Final string
|
esac
|
||||||
theme="${gtk2theme}${gtk3theme}"
|
|
||||||
theme=${theme//\"}
|
|
||||||
theme=${theme//\'}
|
|
||||||
|
|
||||||
# If the final string is empty print "None"
|
|
||||||
[ -z "$theme" ] && theme="None"
|
|
||||||
|
|
||||||
# Make the output shorter by removing "[GTKX]" from the string
|
|
||||||
if [ "$gtk_shorthand" == "on" ]; then
|
|
||||||
theme=${theme/ '[GTK2]'}
|
|
||||||
theme=${theme/ '[GTK3]'}
|
|
||||||
theme=${theme/ '[GTK2/3]'}
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1565,27 +1576,6 @@ getcols () {
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# Windows Visual Style {{{
|
|
||||||
|
|
||||||
getvisualstyle () {
|
|
||||||
case "$os" in
|
|
||||||
"Windows"*)
|
|
||||||
path="/proc/registry/HKEY_CURRENT_USER/Software/Microsoft"
|
|
||||||
path+="/Windows/CurrentVersion/Themes/CurrentTheme"
|
|
||||||
visualstyle="$(head -n1 $path)"
|
|
||||||
visualstyle="${visualstyle##*\\}"
|
|
||||||
visualstyle="${visualstyle%.*}"
|
|
||||||
visualstyle="${visualstyle^}"
|
|
||||||
;;
|
|
||||||
|
|
||||||
*)
|
|
||||||
visualstyle="This feature only works on Windows"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
# }}}
|
|
||||||
|
|
||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
Reference in New Issue