Arrêter KDE en ligne de commande

Par défaut
Bien pratique parfois quand KDE (kwin par exemple) est bien planté :
# /bin/sh
# Written by cz0 2010
# Distributed under the terms of the GNU General Public License v2
 
SU="/bin/su"
QDBUS="/usr/bin/qdbus"
TIMEOUT="20"
USER="$(/usr/bin/whoami)"
 
for KDEPID in $(ps aux | grep 'startkde' | grep -v 'grep' | awk '{print $2}'); do
        KDEUSER=$(ps u $KDEPID | grep 'startkde' | awk '{print $1}')
 
        if [[ "$KDEUSER" != "$USER" && "$USER" != "root" ]] ; then
                logger "kde4_shutdown: unable to stop KDE session of user $KDEUSER"
                exit 67
        fi
 
        CURRENT_DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$(ps h --ppid $KDEPID -o pid | awk '{print $1}')/environ | sed -e 's/DBUS_SE>
        export DBUS_SESSION_BUS_ADDRESS=$CURRENT_DBUS_SESSION_BUS_ADDRESS
 
        logger  "kde4_shutdown: sending shutdown signal to KDE session pid=$KDEPID owner uid=$KDEUSER via $DBUS_SESSION_BUS_ADDRESS"
 
        if [[ "$USER" == "root" ]] ; then
                $SU -c "$QDBUS org.kde.ksmserver /KSMServer logout 0 0 0" $KDEUSER
        else
                $QDBUS org.kde.ksmserver /KSMServer logout 0 0 0
        fi
 
        while [[ "$(ps h --ppid $KDEPID -o pid)" != "" && $TIMEOUT > 0 ]] ; do
                sleep 1s
                let "TIMEOUT -= 1"
        done
done