#!/bin/sh

if [ $(id -u) -eq 0 ]; then
    # If we're the system sch-client
    reboot
else
    # We're the user sch-client, so properly exit the session

    # Notify ldm that we want to reboot after logoff
    xprop -root -f LTSP_LOGOUT_ACTION 8s -set LTSP_LOGOUT_ACTION REBOOT

    # Gnome
    dbus-send --session --dest=org.gnome.SessionManager --type=method_call --print-reply --reply-timeout=2000 /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1

    # TODO: KDE and other DEs
fi
