#!/bin/sh
#
# /etc/X11/wdm/Xreset
#
# This script is run as root after any X session ends.

#set -x

# First run /etc/syslogout being $USER
su - $USER -c "if [ -f /etc/syslogout ]; then . /etc/syslogout; fi"

# Remove the utmp entry for the session
if grep -q ^use-sessreg /etc/X11/wdm/wdm.options; then
  sessreg -d -l $DISPLAY -u /var/run/utmp -x /etc/X11/wdm/Xservers $USER
fi

# This must be done here as opposed to in the Xsetup scripts as 
# they are run after wdm has initialized its session menu, so 
# any changes made there won't be reflected in the current menu
if grep -q ^auto-update-wmlist /etc/X11/wdm/wdm.options; then
  update_wdm_wmlist
fi

exit 0
