#!/bin/bash
installed=$(dpkg -l |grep xserver-xorg |awk '{print $2}')
running=$(grep "LoadModule" /var/log/Xorg.0.log |sed -e 's/\"//g'|awk '{print $3}')
running="vesa dummy $running"
modlist=""
for module in $installed
do
cur_name=${module##*input-}
if test "$cur_name" == "$module"
then # we must filter the word video
cur_name=${module##*video-}
if test "$cur_name" == "$module"
then # we must filter the word video
modtype="undef"
else
modtype="video"
fi
else
modtype="input"
fi
if test "$modtype" == "undef"
then
echo skipping...
else
echo "Module $cur_name is $modtype"
# now if the module is in the actual loaded list we skip it otherwise we add him to the
# list of the modules to be removed
is_in=$(echo $running |grep -i $cur_name |wc -l)
if test $is_in -eq 1
then
echo "Module $module from type $modtype is currently used"
else
echo "Module $module vom type $modtype is not currently used"
modlist="$modlist $module"
fi
fi
done
echo "Following modules could be deinstalled: "
echo "$modlist"