#!/bin/bash

# first get helper functions (e.g. DEBUG, load_scheme, ...)
. "${0%/*}/helper_functions"
. "${SCRIPT_DIR}/x_helper_functions"

get_x_user
DEBUG "Logging out of kde for user: $X_USER" INFO
[ -n "$X_USER" -a -n "$DISP" ] && su $X_USER -s /bin/bash -c "DISPLAY=$DISP /opt/kde3/bin/dcop ksmserver ksmserver logout 0 0 0"
if [ $? != "0" ]; then
    DEBUG "Could not log out user '$X_USER' out of KDE display '$DISP'." DIAG
    $SCRIPT_RETURN $EV_ID 1 "Could not log out user $X_USER out of KDE display $DISP"
    EXIT 1
fi
$SCRIPT_RETURN $EV_ID 0 "wm_logout finished"
EXIT 0
