#!/bin/sh

#update-desktop-database #~/.local/share/applications/
#update-mime-database #~/.local/share/mime/
#gtk-update-icon-cache ~/.local/share/icons/hicolor/ -t

[ -d "$1/usr/share/mime/" ] && update-mime-database /usr/share/mime &
[ -d "$1/usr/lib/gdk-pixbuf-2.0/" ]  && gdk-pixbuf-query-loaders --update-cache &
#[ -d "$1/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -f -i -q /usr/share/icons/hicolor &
find /usr/share/icons -mindepth 1 -maxdepth 1 -type d | while read -r THEME; do
  if [ -f "$THEME/index.theme" ]; then
    gtk-update-icon-cache -f -q "$THEME" 2>/dev/null
  fi
done
[ -d "$1/usr/share/glib-2.0/schemas/" ]  && glib-compile-schemas /usr/share/glib-2.0/schemas/ &
if [ -d "$1/usr/share/applications/" -o -d "$1/usr/local/share/applications/" ]; then 
	update-desktop-database -q 2>/dev/null &
	touch /usr/share/applications/screensavers
fi
for font_dir in /usr/share/fonts{,/default}/TTF  /usr/X11R6/lib/X11/fonts/TTF; do
    if [ -d "$1/${font_dir}" ]; then
	fcneed=on
	mkfontscale ${font_dir} 
	mkfontdir ${font_dir}
    fi
done
[ $fcneed ] && fc-cache -f -s
