#!/bin/bash

#
#  Dieses Script blendet Symbole aus dem Starmenue aus,
#  die nicht fuer Endkunden notwendig sind.
#
#  Autor: Marcus Orthbandt, PC-vor-Ort Rutesheim
# 

PATH=/sbin:/bin:/usr/sbin:/usr/bin
USERNAME=$(whoami)

# Reset LightDM
#rm /home/*/.dmrc >>/dev/null 2>&1
#rm /var/cache/lightdm/dmrc/* >>/dev/null 2>&1
#rm /var/lib/lightdm/.cache/lightdm-gtk-greeter/state >>/dev/null 2>&1
#ls /usr/share/xsessions/*.desktop | while read a; do
#  if [ "x$a" != "x/usr/share/xsessions/xlinux.desktop" ]; then
#    mv ${a} ${a}.deaktiviertxlinux
#  fi
#done

function hide_entry {
  ls $1 | while read a; do
    #v=`grep -c "NoDisplay=true" $a`
    #echo $a $v;
    #if [ "$v" == "0" ]; then
    #  echo "NoDisplay=true" >> $a
    #fi
    mv $a $a.xlinuxdisabled
  done
}


#sed -i 's/^Categories=.*/Categories=Settings;X-XFCE-SettingsDialog;X-XFCE-PersonalSettings;/' /usr/share/applications/mugshot.desktop
#sed -i 's/^Categories=Settings;/Categories=Settings;X-XFCE-SettingsDialog;/' /usr/share/applications/*.desktop
#sed -i 's/^Categories=.*;Settings;/Categories=Settings;X-XFCE-SettingsDialog;/' /usr/share/applications/*.desktop

if [ -f "/etc/xdg/autostart/pvo-xlinux-userstartup.desktop" ]; then
  rm "/etc/xdg/autostart/pvo-xlinux-userstartup.desktop"
fi

#if [ $USERNAME == "root" ]; then
  hide_entry "/usr/share/applications/Thunar.desktop"
  hide_entry "/usr/share/applications/Thunar-*.desktop"
  hide_entry "/usr/share/applications/thunar*.desktop"
  hide_entry "/usr/share/applications/icedtea-netx-javaws.desktop"
  hide_entry "/usr/share/applications/itweb-settings.desktop"
  hide_entry "/usr/share/applications/evince-previewer.desktop"
  hide_entry "/usr/share/applications/yelp.desktop"
  hide_entry "/usr/share/applications/openjdk-*.desktop"
  hide_entry "/usr/share/applications/x11vnc.desktop"
  hide_entry "/usr/share/applications/debian-*term.desktop"
  hide_entry "/usr/share/applications/xfce4-web-browseer.desktop"
  hide_entry "/usr/share/applications/xfce4-terminal.desktop"
  hide_entry "/usr/share/applications/xfce4-terminal-settings.desktop"
  hide_entry "/usr/share/applications/system-config-printer.desktop"
#fi

# Entfernen von System-Dateizuweisungen. Dadurch wird /usr/share/xlinux/applications/mimeapps.list aktiv
if [ -f "/etc/xdg/mimeapps.list" ]; then
  d=$(date +%Y%m%d_%H%M)
  mv /etc/xdg/mimeapps.list /etc/xdg/mimeapps.list.$d >/dev/null 2>&1
fi
